Board index » delphi » How to extarct Time from the given date

How to extarct Time from the given date

Hi,
 I am facing the problem in extracting the Hour from the  given date field.
I have used the CAST() function to convert the datatype. If I use the
Extract() function, its giving aan error.
Suggest something on extracting the 'HH:MM:SS' from the given field.
Regards
ram
 

Re:How to extarct Time from the given date


Have you tried this?

var
    Hour, Min, Sec, MSec : Word ;
begin
    DecodeTime(  YourDataSet.FieldByName(YourFieldName).AsDateTime, Hour,
Min, Sec, MSec ) ;
//   ... Here, in Hour, you got it.
end;

Quote
Ram <vella...@infoglobe.com> wrote in message

news:84d6pr$s712@forums.borland.com...
Quote
> Hi,
>  I am facing the problem in extracting the Hour from the  given date
field.
> I have used the CAST() function to convert the datatype. If I use the
> Extract() function, its giving aan error.
> Suggest something on extracting the 'HH:MM:SS' from the given field.
> Regards
> ram

Re:How to extarct Time from the given date


See the DecodeTime function in the on-line help.

--
Bill

Bill Todd (TeamB)
(TeamB cannot respond to questions received via email)

Re:How to extarct Time from the given date


Quote
On Wed, 29 Dec 1999 09:49:37 -0500, "Ram" <vella...@infoglobe.com> wrote:
> I am facing the problem in extracting the Hour from the  given date field.
>I have used the CAST() function to convert the datatype. If I use the
>Extract() function, its giving aan error.
>Suggest something on extracting the 'HH:MM:SS' from the given field.

Using the EXTRACT function with the HOUR keyword works for me (BDE 5.x).
What version of the BDE are you using? What is the field type? What was the
exact statement you were using? (Follow-ups to the newsgroup only, please.)

Here is an example, where the column DT is a TIMESTAMP type column in a
Paradox table.

  SELECT DT, EXTRACT(HOUR FROM DT) AS HH
  FROM "TheTable.db"

Local SQL (what the BDE uses for dBASE, Paradox, and FoxPro tables) is
documented in the online help file LOCALSQL.HLP, found in the main BDE
directory. This help file is a language reference of the local SQL
implementation (subset) of SQL-92. The copy of this file that came with BDE
4.x (and earlier versions) was outdated and has since been rewritten.
Updated copies will have the topic "Unsupported language" in the index (and
lack of this topic indicates a pre-update copy). I can e-mail you a copy of
the updated file if you need and desire it.

_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
Steve Koterski              "Health nuts are going to feel stupid someday,
Felton, CA                  lying in hospitals dying of nothing."
                                                              -- Redd Foxx

Other Threads