find out date 12 weeks ago

Hey there,

I wanna find out the date subtracted 12 weeks from today. Do I have to build a whole calendar and then read from it?

example:
Today: 20130109
Result: 20121017

maybe anyone has already written a script for that?

any help appreciated
Roman [import]uid: 140000 topic_id: 34756 reply_id: 334756[/import]

like most of the time I’m answering my own questions (sorry for the spam, maybe helpful to others):

-- current date t = os.time(); d = os.date("%Y-%m-%d", t); print("Today", d ); -- - 7 \* 12 days t = t - 604800 \* 12; d = os.date("%Y-%m-%d", t); print("Next week", d ); [import]uid: 140000 topic_id: 34756 reply_id: 138102[/import]

For more complex date calculations, check out this neat Data library
http://luaforge.net/projects/date/ [import]uid: 64174 topic_id: 34756 reply_id: 138109[/import]

like most of the time I’m answering my own questions (sorry for the spam, maybe helpful to others):

-- current date t = os.time(); d = os.date("%Y-%m-%d", t); print("Today", d ); -- - 7 \* 12 days t = t - 604800 \* 12; d = os.date("%Y-%m-%d", t); print("Next week", d ); [import]uid: 140000 topic_id: 34756 reply_id: 138102[/import]

For more complex date calculations, check out this neat Data library
http://luaforge.net/projects/date/ [import]uid: 64174 topic_id: 34756 reply_id: 138109[/import]