# dateparser

### Installation

You can install dateparser from the OutSystems Forge component page:\
<https://www.outsystems.com/forge/component-overview/14418/dateparser>

### Public API

* ![ServiceAPIMethod](https://ik.imagekit.io/antunes/os-resources/tr:w-18,h-18/ServiceAPIMethod.png) **Parse**&#x20;

  *Attempts to parse a string into a DateTime (exceptions are raised).*

  * ![InputParameter](https://ik.imagekit.io/antunes/os-resources/tr:w-18,h-18/InputParameter.png) **String** *(Text, Mandatory)*
  * ![InputParameter](https://ik.imagekit.io/antunes/os-resources/tr:w-18,h-18/InputParameter.png) **Type** *(Integer)*

    *Past = -1, Future = 1, None = 0*
  * ![OutputParameter](https://ik.imagekit.io/antunes/os-resources/tr:w-18,h-18/OutputParameter.png) **DateTime** *(*&#x44;ateTim&#x65;*)*
* ![ServiceAPIMethod](https://ik.imagekit.io/antunes/os-resources/tr:w-18,h-18/ServiceAPIMethod.png) **TryParse**
  * ![InputParameter](https://ik.imagekit.io/antunes/os-resources/tr:w-18,h-18/InputParameter.png) **String** *(Text, Mandatory)*

    *e.g.: may 27th*
  * ![InputParameter](https://ik.imagekit.io/antunes/os-resources/tr:w-18,h-18/InputParameter.png) **Type** *(Integer)*

    *Past = -1, Future = 1, None = 0*
  * ![OutputParameter](https://ik.imagekit.io/antunes/os-resources/tr:w-18,h-18/OutputParameter.png) **DateTime** *(*&#x44;ateTim&#x65;*)*

### Examples

<figure><img src="https://496068419-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5aUfxHz32VNZfq3FdkuR%2Fuploads%2FmZhcGP5fG30zdluPmSES%2Fsnapp-image%20(6).jpeg?alt=media&#x26;token=99c9b901-b058-4401-bec7-8e99f4dde231" alt=""><figcaption><p>dateparser demo app</p></figcaption></figure>

dateparser can parse a huge variety of date and time formats. Following is a small sample of strings that will be properly parsed. Parsing is case-insensitive and will handle common abbreviations and misspellings.

For the cases where temporal time is not specific, it's possible to set ***Type*** parameter to indicate if the parsing should take into consideration past or future dates.&#x20;

Example:

```
Parse "monday", type:past   = 2022-12-26 12:00:00
Parse "monday", type:future = 2023-01-02 12:00:00
```

**Simple**

* last friday at 20:00 ([try it](https://miguel-antunes.outsystemscloud.com/dateparserDemo/Demo?s=last%20friday%20at%2020:00))
* last week tuesday ([try it](https://miguel-antunes.outsystemscloud.com/dateparserDemo/Demo?s=last%20week%20tuesday))
* tomorrow at 6:45pm ([try it](https://miguel-antunes.outsystemscloud.com/dateparserDemo/Demo?s=tomorrow%20at%206:45pm))
* thursday last week ([try it](https://miguel-antunes.outsystemscloud.com/dateparserDemo/Demo?s=thursday%20last%20week))

**Complex**

* 3 years ago ([try it](https://miguel-antunes.outsystemscloud.com/dateparserDemo/Demo?s=3%20years%20ago))
* 5 months before now ([try it](https://miguel-antunes.outsystemscloud.com/dateparserDemo/Demo?s=5%20months%20before%20now))
* 7 hours ago ([try it](https://miguel-antunes.outsystemscloud.com/dateparserDemo/Demo?s=7%20hours%20ago))
* 7 days from now ([try it](https://miguel-antunes.outsystemscloud.com/dateparserDemo/Demo?s=7%20days%20from%20now))
* 1 week hence ([try it](https://miguel-antunes.outsystemscloud.com/dateparserDemo/Demo?s=1%20week%20hence))
* 3 months ago saturday at 5:00 pm ([try it](https://miguel-antunes.outsystemscloud.com/dateparserDemo/Demo?s=3%20months%20ago%20saturday%20at%205:00%20pm))
* 3rd month next year ([try it](https://miguel-antunes.outsystemscloud.com/dateparserDemo/Demo?s=3rd%20month%20next%20year))
* 3rd thursday this september ([try it](https://miguel-antunes.outsystemscloud.com/dateparserDemo/Demo?s=3rd%20thursday%20this%20september))
* 4th day last week ([try it](https://miguel-antunes.outsystemscloud.com/dateparserDemo/Demo?s=4th%20day%20last%20week))
* fourteenth of june 2010 at eleven o'clock in the evening ([try it](https://miguel-antunes.outsystemscloud.com/dateparserDemo/Demo?s=fourteenth%20of%20june%202010%20at%20eleven%20o%27clock%20in%20the%20evening))
* may seventh '97 at three in the morning ([try it](https://miguel-antunes.outsystemscloud.com/dateparserDemo/Demo?s=may%20seventh%20%2797%20at%20three%20in%20the%20morning))

**Specific Dates**

* January 5 ([try it](https://miguel-antunes.outsystemscloud.com/dateparserDemo/Demo?s=January%205))
* 22nd of june ([try it](https://miguel-antunes.outsystemscloud.com/dateparserDemo/Demo?s=22nd%20of%20june))
* 5th may 2017 ([try it](https://miguel-antunes.outsystemscloud.com/dateparserDemo/Demo?s=5th%20may%202017))
* February twenty first ([try it](https://miguel-antunes.outsystemscloud.com/dateparserDemo/Demo?s=February%20twenty%20first))
* dec 25 ([try it](https://miguel-antunes.outsystemscloud.com/dateparserDemo/Demo?s=dec%2025))
* february 14, 2004
* february 14th, 2004 ([try it](https://miguel-antunes.outsystemscloud.com/dateparserDemo/Demo?s=february%2014th,%202004))
* 17 april 85 ([try it](https://miguel-antunes.outsystemscloud.com/dateparserDemo/Demo?s=17%20april%2085))
* 27/5/1979 ([try it](https://miguel-antunes.outsystemscloud.com/dateparserDemo/Demo?s=27/5/1979))
* etc.

### Demo

You can see the component demo [here](https://miguel-antunes.outsystemscloud.com/dateparserDemo/Demo).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://miguel-antunes-outsystems-forge.gitbook.io/docs/components/dateparser.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
