Navigation:  thinBasic Modules > DT (Date Handling) >

DT_DateFormat

Previous pageReturn to chapter overviewNext page

 

Description

 

The DT_DateFormat() function formats a date according on a given date mask.

 

Syntax

 

DT_DateFormat(sDate AS STRING, sFormat AS STRING) AS STRING

 

Returns

 

Returns AS STRING

  Returns a date string as request.

 

Parameters

 

sDate AS STRING

The date string, if empty the function will use the current date but always return a native date string (ignore the sFormat parameter)

       sFormat AS STRING

Specify the format to assign to the date string, use the following elements to construct a format mask string:

       

Mask        Description        

D        Day of month as digits with no leading zero for single-digit days.        

Dd        Day of month as digits with leading zero for single-digit days.        

ddd        Day of week as a three-letter abbreviation. The function uses the LOCALE_SABBREVDAYNAME value associated with the specified locale.        

dddd        Day of week as its full name. The function uses the LOCALE_SDAYNAME value associated with the specified locale.        

M        Month as digits with no leading zero for single-digit months.        

MM        Month as digits with leading zero for single-digit months.        

MMM        Month as a three-letter abbreviation. The function uses the LOCALE_SABBREVMONTHNAME value associated with the specified locale.        

MMMM        Month as its full name. The function uses the LOCALE_SMONTHNAME value associated with the specified locale.        

Y        Year as last two digits, but with no leading zero for years less than 10.        

Yy        Year as last two digits, but with leading zero for years less than 10.        

yyyy        Year represented by full four digits.        

Gg        Period/era string. The function uses the CAL_SERASTRING value associated with the specified locale. This element is ignored if the date to be formatted does not have an associated era or period string.        

               

 

Remarks

 

If you use spaces to separate the elements in the format string, these spaces will appear in the same location in the output string. The letters must be in uppercase or lowercase as shown in the table (for example, "MM" not "mm"). Characters in the format string that are enclosed in single quotation marks will appear in the same location and unchanged in the output string.

Restrictions

 

 

See also

 

  DT_CookieDate, DT_TimeFormat

Examples

 

MSGBOX 0, DT_DateFormat("06-15-2005", "yyyy.MM.dd") ' results '2005.06.15'

 

 

© 2004-2008 thinBasic. All rights reserved. Version 1.7.0.0 Web Site: http://www.thinbasic.com