Date Convertion function doubt
Date Convertion function doubt
Hi,
Is there a function available to convert date into the Following Format
"07-Jan-2010"
Date() -> "07-Jan-2010"
Regards
Anser
Is there a function available to convert date into the Following Format
"07-Jan-2010"
Date() -> "07-Jan-2010"
Regards
Anser
- nageswaragunupudi
- Posts: 10721
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Been thanked: 8 times
- Contact:
Re: Date Convertion function doubt
use fwh function:
cValToStr( dDate, 'dd-mmm-yyyy' )
This function works independent of the date format setting.
you can use dd, mm, mmm, mmmm in any order
for example 'mmmm dd, yyyy' produces October 23, 2009
This is the function XBrowse uses internally. We can oCol:cEditPicture in this format for date values.
cValToStr( dDate, 'dd-mmm-yyyy' )
This function works independent of the date format setting.
you can use dd, mm, mmm, mmmm in any order
for example 'mmmm dd, yyyy' produces October 23, 2009
This is the function XBrowse uses internally. We can oCol:cEditPicture in this format for date values.
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
-
- Posts: 18
- Joined: Wed Nov 04, 2009 9:41 am
Re: Date Convertion function doubt
Hi Anserkk,
Try this:
function main ()
local a,b,c
a := Str(Day(Date()))
b := CMonth(Date())
c := Str(Year(Date()))
MSGINFO(a+ "-" +b+ "-" +c)
return nil
The result is: "7-January-2010"
Regards.
Try this:
function main ()
local a,b,c
a := Str(Day(Date()))
b := CMonth(Date())
c := Str(Year(Date()))
MSGINFO(a+ "-" +b+ "-" +c)
return nil
The result is: "7-January-2010"
Regards.
Re: Date Convertion function doubt
Dear Mr.Rao,
Thank you. cValToStr( dDate, 'dd-mmm-yyyy' ) served my purpose.
Hope I can use the same function to convert 24 Hrs. time format to 12 Hrs AM/PM format.
Where can I get more information on the formats supported by cValToStr(). In Five Wiki I did not find the write up for cValToStr(), but information on cValToChar is available.
Dear Mr.DiegoCandel,
Thank you for your support
. I was checking whether a built in function is available or not.
Regards
Anser
Thank you. cValToStr( dDate, 'dd-mmm-yyyy' ) served my purpose.
Hope I can use the same function to convert 24 Hrs. time format to 12 Hrs AM/PM format.
Where can I get more information on the formats supported by cValToStr(). In Five Wiki I did not find the write up for cValToStr(), but information on cValToChar is available.
Dear Mr.DiegoCandel,
Thank you for your support
![Smile :)](./images/smilies/icon_smile.gif)
Regards
Anser
Re: Date Convertion function doubt
Hi all,
To convert 24 hrs time format to 12 Hrs AM/PM format we can use the Function AmPm(cTime)
Regards
Anser
To convert 24 hrs time format to 12 Hrs AM/PM format we can use the Function AmPm(cTime)
Regards
Anser
- nageswaragunupudi
- Posts: 10721
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Been thanked: 8 times
- Contact:
Re: Date Convertion function doubt
This function is not yet documented on fivewiki, but you can search the whatsnew.txt.
no. it does not support hours and minutes still
no. it does not support hours and minutes still
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
- nageswaragunupudi
- Posts: 10721
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Been thanked: 8 times
- Contact:
Re: Date Convertion function doubt
Mr. Anser
I feel dealing with date and time values separately have become things of past. Now datetime variables can be used directly.
All RDMS support datetime. Even present day DBFCDX supports datetime fields. Through ADO or RDD, we read and write datetime values directly as single variables. Why should we deal with date and time parts separately and still use the older functions?
Please look at this xHarbour code. ( Slightly different in Harbour )
Results are :
08-01-2010 01:15:00 AM
01:15:00 AM
08 JAN 2010 01:15:00 AM
I feel dealing with date and time values separately have become things of past. Now datetime variables can be used directly.
All RDMS support datetime. Even present day DBFCDX supports datetime fields. Through ADO or RDD, we read and write datetime values directly as single variables. Why should we deal with date and time parts separately and still use the older functions?
Please look at this xHarbour code. ( Slightly different in Harbour )
Code: Select all | Expand
local tDate
SET DATE ITALIAN
SET TIME FORMAT TO 'HH:MM:SS PM'
tDate := DateTime()
MsgInfo( TtoC( tDate ) )
MsgInfo( TtoC( tDate, 2 ) )
MsgInfo( cValToStr( tDate, 'DD-MMM-YYYY' ) + ' ' + TToC( tDate, 2 ) )
Results are :
08-01-2010 01:15:00 AM
01:15:00 AM
08 JAN 2010 01:15:00 AM
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
Re: Date Convertion function doubt
Dear Mr.Rao,
I am yet to learn many existing functions in xHarbour and FiveWin. I was not aware of the function DateTime() and TtoC( tDate, 2 )
In my MS-Sql database I am using DateTime type column and I extracted the Time part from it as a seperate column in the recordset using the following Sql
If knew the functions DateTime() and TtoC(), then I would have extracted the Date and Time separately from a DateTime column using FiveWin itself.
I need the Time part separately for some reporting purpose.
The following command would serve my purpose
Using the AMPM() with the above functions, I don't have to use the SET TIME FORMAT TO command
Once again I thank you for the support.
Regards
Anser
I am yet to learn many existing functions in xHarbour and FiveWin. I was not aware of the function DateTime() and TtoC( tDate, 2 )
I feel dealing with date and time values separately have become things of past. Now datetime variables can be used directly.
In my MS-Sql database I am using DateTime type column and I extracted the Time part from it as a seperate column in the recordset using the following Sql
Code: Select all | Expand
SELECT Branch_Short_Name, Last_Upload, CONVERT(varchar(10), Last_Upload, 108) as UploadTime FROM Branches
If knew the functions DateTime() and TtoC(), then I would have extracted the Date and Time separately from a DateTime column using FiveWin itself.
I need the Time part separately for some reporting purpose.
The following command would serve my purpose
Code: Select all | Expand
cValToStr( tDate, 'DD-MMM-YYYY' ) + ' ' + TToC( tDate, 2 )
Using the AMPM() with the above functions, I don't have to use the SET TIME FORMAT TO command
Once again I thank you for the support.
Regards
Anser
- nageswaragunupudi
- Posts: 10721
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Been thanked: 8 times
- Contact:
Re: Date Convertion function doubt
I read the column values directly into a single datetime variable and use for further computations. Straight Sql.
Can always display date part or time part separately or together.
Can always display date part or time part separately or together.
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India