| Subject |
Re: DATE format |
| From |
Gaetano <gaetanodd@hotmail.com> |
| Date |
Thu, 5 Nov 2020 06:33:30 +1000 |
| Newsgroups |
dbase.getting-started |
Hi Mustansir,
There is unfortunately no DTTOS() (DateTimeToString) function in dBase.
You can either temporarily change the format as Mervyn suggested,
however, you may need to store the Mark setting (i.e. date separator -
cMark = set('Mark')) to reset it when switching back to your local
format as I believe that dBase uses the "-" mark by default when
switching formats), or you can try this function I wrote to produce the
format you are looking for.
function DTTOS(dDT)
/* must supply dateTime value, e.g. from a dBase Timestamp field or
{literal datetime} in valid local format, a date object or the datetime
function
Usage:
?dttos(datetime())
?dttos({14/1/2020 14:00:00})
?dttos(oRowset.fields["transactionTimeStamp"].value)
form.entryField1.value = dttos(oRowset.fields["transactionTimeStamp"].value)
*/
local dDate,tTime,cRet
dDate = substr(DTOS(dDT),1,4)+"-"+substr(DTOS(dDT),5,2)+
"-"+substr(DTOS(dDT),7,2)
tTime = TTOC(dDT)
cRet = dDate+" "+tTime
return cRet
Cheers,
Gaetano.
On 05/11/2020 03:40, Mervyn Bick wrote:
> On 2020/11/04 18:25, Mustansir Ghor wrote:
>> Dear All
>>
>> I wish to get format of datetime() function to display YYYY-MM-DD
>> HH:MM:SS.
>>
>> Can anybody advise how this can be achieved
>>
>> Best Regards
>> Mustansir
>>
>
> With the date set to YMD datetime() displays YYYY-MM-DD HH:MM:SS
>
> dBASE 2109 with Windows 10 Pro, 64-bit, version 2004.
>
> See attached screenprint.
>
> Mervyn.
|
|