# format specific datetime parse

**URL:** <https://forum.kx.com/t/format-specific-datetime-parse/7957>\
**Category:** Community Support\
**Tags:** kdb-and-q\
**Created:** [October 15, 2012, 1:43am UTC](https://forum.kx.com/t/format-specific-datetime-parse/7957 "2012-10-15T01:43:00Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sam11](https://avatars.discourse-cdn.com/v4/letter/s/c6cbf5/32.png) [@Sam11](https://forum.kx.com/u/Sam11)\
**Post date:** [October 15, 2012, 1:43am UTC](https://forum.kx.com/t/format-specific-datetime-parse/7957/1 "2012-10-15T01:43:00Z")

</div>

Hi,  
If I understand correctly, the default datetime cast expects the string to be in&nbsp;&nbsp;YYYYMMDD, MM/DD/YYYY&nbsp;format. Is there a way to specify the format explicitly for parsing? I’ve some data in DD/MM/YYYY format and other formats and having trouble parsing it in Q. &nbsp;

thanks

---

<div class="post-metadata">

**Author:** ![Sam11](https://avatars.discourse-cdn.com/v4/letter/s/c6cbf5/32.png) [@Sam11](https://forum.kx.com/u/Sam11)\
**Post date:** [October 15, 2012, 1:45am UTC](https://forum.kx.com/t/format-specific-datetime-parse/7957/2 "2012-10-15T01:45:00Z")

</div>

For example:

q)“D”$“16/09/2012 14:33:32”

0Nd

---

<div class="post-metadata">

**Author:** ![Sam11](https://avatars.discourse-cdn.com/v4/letter/s/c6cbf5/32.png) [@Sam11](https://forum.kx.com/u/Sam11)\
**Post date:** [October 15, 2012, 2:17am UTC](https://forum.kx.com/t/format-specific-datetime-parse/7957/3 "2012-10-15T02:17:00Z")

</div>

I also want to note that I am reading the file using 0: and it is not possible to manipulate the strings..

---

<div class="post-metadata">

**Author:** ![abcfoots1](https://avatars.discourse-cdn.com/v4/letter/a/96bed5/32.png) [@abcfoots1](https://forum.kx.com/u/abcfoots1)\
**Post date:** [October 15, 2012, 2:18am UTC](https://forum.kx.com/t/format-specific-datetime-parse/7957/4 "2012-10-15T02:18:00Z")

</div>

[code.kx.com](http://code.kx.com) is really worth reading

q)\z 1

q)“d”$“Z”$“16/09/2012 14:33:32”

2012.09.16

---

<div class="post-metadata">

**Author:** ![Sam11](https://avatars.discourse-cdn.com/v4/letter/s/c6cbf5/32.png) [@Sam11](https://forum.kx.com/u/Sam11)\
**Post date:** [October 15, 2012, 3:58am UTC](https://forum.kx.com/t/format-specific-datetime-parse/7957/5 "2012-10-15T03:58:00Z")

</div>

Thnks. I did a lot of searching, reading and experimentation before posting it here. Unfortunately, there is no specific topic on datetime anywhere.

| -z, \z | date format |

doesn’t really explain anything. Thanks :)

---

<div class="post-metadata">

**Author:** ![charlie1](https://avatars.discourse-cdn.com/v4/letter/c/ec9cab/32.png) [@charlie1](https://forum.kx.com/u/charlie1)\
**Post date:** [October 15, 2012, 10:34am UTC](https://forum.kx.com/t/format-specific-datetime-parse/7957/6 "2012-10-15T10:34:00Z")

</div>

Maybe it is easily overlooked. Searching code.kx.com for “date format” -

http://code.kx.com/wiki/JB:QforMortals2/commands\_and\_system\_variables#Date\_Format\_.28-z.29

Date Format (-z)

The date format parameter is a boolean value that specifies the format expected in date parsing. A value of 0 corresponds to mm/dd/yyyy; a value of 1 corresponds to dd/mm/yyyy. This parameter corresponds to the command \z.

---

<div class="post-metadata">

**Author:** ![Sam11](https://avatars.discourse-cdn.com/v4/letter/s/c6cbf5/32.png) [@Sam11](https://forum.kx.com/u/Sam11)\
**Post date:** [October 15, 2012, 10:19pm UTC](https://forum.kx.com/t/format-specific-datetime-parse/7957/7 "2012-10-15T22:19:00Z")

</div>

Yes, I was able to figure it out. Actually the search tool is pretty cool. The google search on this wasn’t helpful.

Its good to have a thread here in case someone else comes here seeking help on this :)

---

<div class="post-metadata">

**Author:** ![greg\_heil](https://avatars.discourse-cdn.com/v4/letter/g/d78d45/32.png) [@greg\_heil](https://forum.kx.com/u/greg_heil)\
**Post date:** [October 19, 2012, 8:01pm UTC](https://forum.kx.com/t/format-specific-datetime-parse/7957/8 "2012-10-19T20:01:00Z")

</div>

The Google “site” operator is usefulsite:code.kx.com "date format"greg~krsnadas.org–from: Sam jain.samit@gmail.comto: personal-kdbplus@googlegroups.comdate: 15 October 2012 14:19subject: Re: [personal kdb+] Re: format specific datetime parseYes, I was able to figure it out. Actually the search tool is prettycool. The google search on this wasn’t helpful.Its good to have a thread here in case someone else comes here seekinghelp on this :)–from: Charles Skelton charlie@kx.comto: personal-kdbplus@googlegroups.comdate: 15 October 2012 02:34subject: Re: [personal kdb+] Re: format specific datetime parseMaybe it is easily overlooked. Searching [code.kx.com](http://code.kx.com) for “date format” -[http://code.kx.com/wiki/JB:QforMortals2/commands](http://code.kx.com/wiki/JB:QforMortals2/commands)\_and\_system\_variables#Date\_Format\_.28-z.29Date Format (-z)The date format parameter is a boolean value that specifies the formatexpected in date parsing. A value of 0 corresponds to mm/dd/yyyy; avalue of 1 corresponds to dd/mm/yyyy. This parameter corresponds tothe command \z.–On Mon, Oct 15, 2012 at 4:58 AM, Sam \<jain.samit\> wrote:Thnks. I did a lot of searching, reading and experimentation beforeposting it here. Unfortunately, there is no specific topic on datetimeanywhere.-z, \z date formatdoesn’t really explain anything. Thanks :)–On Sunday, October 14, 2012 9:18:48 PM UTC-4, abcfoots wrote:code.kx.com is really worth readingq)\z 1q)“d”$“Z”$"16/09/2012 14:33:32"2012.09.16–On Sunday, October 14, 2012 8:45:37 PM UTC-4, Sam wrote:For example:q)“D”$"16/09/2012 14:33:32"0Nd–On Sunday, October 14, 2012 8:43:49 PM UTC-4, Sam wrote:Hi,If I understand correctly, the default datetime cast expects thestring to be in YYYYMMDD, MM/DD/YYYY format. Is there a way to specifythe format explicitly for parsing? I’ve some data in DD/MM/YYYY formatand other formats and having trouble parsing it in Q.thanks–from: Sam jain.samit@gmail.comto: personal-kdbplus@googlegroups.comdate: 14 October 2012 18:17subject: [personal kdb+] Re: format specific datetime parseI also want to note that I am reading the file using 0: and it is notpossible to manipulate the strings..–On Sunday, October 14, 2012 8:45:37 PM UTC-4, Sam wrote:For example:q)“D”$"16/09/2012 14:33:32"0Nd–On Sunday, October 14, 2012 8:43:49 PM UTC-4, Sam wrote:Hi,If I understand correctly, the default datetime cast expects thestring to be in YYYYMMDD, MM/DD/YYYY format. Is there a way tospecify the format explicitly for parsing? I’ve some data inDD/MM/YYYY format and other formats and having trouble parsing it inQ.thanks\</jain.samit\>
