I grab data from SQL Server in ADODB.Recordset where DateTime data comes as:[tt]
2024-02-07 16:00:00.0000000
2024-04-12 16:00:00.0000000
2023-11-21 16:00:00.0000000
2023-12-18 16:00:00.0000000
2024-01-04 16:00:00.0000000[/tt]
But the Users do not care about time portion. They just want to see the Date.
I know I can do [tt]Cast(MyField As Date) As Whatever[/tt], but I am trying to write something more generic, so I would like to detect DateTime field in my recordset and act upon it.
I did try: [tt]rst.Fields(X).Type[/tt], and I do get Type 202 for DateTime fields, but also I get 202 for nvarchar() fields :-(
My work-around it is:
[tt]If Len(rst.Fields(X).Value) = 27 And IsDate(Left(rst.Fields(X).Value, 10)) Then[/tt]
but I don't like it
Is there a way to detect DateTime field in ADODB recordset?
---- Andy
"Hmm...they have the internet on computers now"--Homer Simpson
2024-02-07 16:00:00.0000000
2024-04-12 16:00:00.0000000
2023-11-21 16:00:00.0000000
2023-12-18 16:00:00.0000000
2024-01-04 16:00:00.0000000[/tt]
But the Users do not care about time portion. They just want to see the Date.
I know I can do [tt]Cast(MyField As Date) As Whatever[/tt], but I am trying to write something more generic, so I would like to detect DateTime field in my recordset and act upon it.
I did try: [tt]rst.Fields(X).Type[/tt], and I do get Type 202 for DateTime fields, but also I get 202 for nvarchar() fields :-(
My work-around it is:
[tt]If Len(rst.Fields(X).Value) = 27 And IsDate(Left(rst.Fields(X).Value, 10)) Then[/tt]
but I don't like it
Is there a way to detect DateTime field in ADODB recordset?
---- Andy
"Hmm...they have the internet on computers now"--Homer Simpson