Domanda

Select distinct Format(DateAdd(""s""," & columnname & ",""1/1/1980 12:00:00 AM""), 'dd-MMM-yyyy') as A

È stato utile?

Soluzione

I have assumed that the seconds to add and the original date are hard coded values below whilst awaiting clarifications requested in the comments.

To add a number of seconds to a date you can use:

select datetime('1980-01-01 00:00:00', "345000 seconds");

This gives the result: 1980-01-04 23:50:00

The example above is just under 4 days in seconds, if you want to truncate the result to just the date as implied by the query in your questions then you can wrap this inside a date function. However, this would give the result in the format "YYYY-MM-DD" rather than "DD-MMM-YYYY" as your access query does.

Unfortunately I cannot find any native SQLite function to convert a numeric month value to mmm format. You can do this manually with replace (similar to the answer to this question), but this is a bit messy.

If you are happy to live with the numeric months then you can simply use:

select strftime('%d-%m-%Y', '1980-01-01 00:00:00', "345000 seconds");

This gives the result: 04-01-1980

More information on the SQLite date / time functions can be found here.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top