Breaking a datetime into components

Is there an easy way to break a datatime into years, months, days,hours, minutes, seconds, milliseconds? I hacked this together, butkept thinking there must be an easier way.q)0N!.z.z; {(year$x;1+(month$x) mod 12;1+(date$x)-date$month$x),floor mod[%[int$`time$x;reverse prds (1;1000;60;60)];(24;60;60;1000)]}.z.z2010.07.02T17:05:22.7682010 7 2 17 5 22 768

To: personal-kdbplus@googlegroups.com
X-Mailer: Apple Mail (2.1081)

q)yearmmddhhuuss$2010.07.02T17:05:22.768
2010 7 2 17 5 22
q)(`time$2010.07.02T17:05:22.768)mod 1000
00:00:00.768

Regards,
Attila
On 2 Jul 2010, at 18:05, Victor Wong wrote:

> Is there an easy way to break a datatime into years, months, days,
> hours, minutes, seconds, milliseconds? I hacked this together, but
> kept thinking there must be an easier way.
>
> q)0N!.z.z; {(year$x;1+(month$x) mod 12;1+(date$x)-date$month \> $x),floor mod[%[int$`time$x;reverse prds (1;1000;60;60)];
> (24;60;60;1000)]}.z.z
> 2010.07.02T17:05:22.768
> 2010 7 2 17 5 22 768
>
> –
> You received this message because you are subscribed to the Google =
Groups “Kdb+ Personal Developers” group.
> To post to this group, send email to =
personal-kdbplus@googlegroups.com.
> To unsubscribe from this group, send email to =
personal-kdbplus+unsubscribe@googlegroups.com.
> For more options, visit this group at =
http://groups.google.com/group/personal-kdbplus?hl=en.
>

timestamp:

q)yearmmddhhuuss$2011.10.06D03:32:26.504000000

2011 10 6 3 32 26

q)(`time$2011.10.06D03:32:26.504000000)mod 1000   /milliseconds

00:00:00.504