Get Date and Time from SQL-Server

DirkSimonDirkSimon Member Posts: 9
Hello,

i want to get data from SQL-Server per ADO. The problem is the field date from the type datetime.

With the following code i get only then date-part of the field:

rs.Open('SELECT TrendNdx, Date, Value FROM ASample WHERE ...
MESSAGE(FORMAT(rs.Fields().Item(1).Value));

Does anybody know, how i can get the time-part?

Dirk

Comments

  • ArhontisArhontis Member Posts: 667
    Maybe you could use the DATEPART routine of the sql (place your data/time filed) on the second parameter. Like:
    SELECT DATEPART(hh,myField) as Hours FROM ....
    
    and use the Hours field on C/Al to get the value...

    DATEPART
    Returns an integer representing the specified datepart of the specified date.

    Syntax
    DATEPART ( datepart , date )

    Arguments
    datepart

    Is the parameter that specifies the part of the date to return. The table lists dateparts and abbreviations recognized by Microsoft® SQL Server™.

    Datepart Abbreviations
    year yy, yyyy
    quarter qq, q
    month mm, m
    dayofyear dy, y
    day dd, d
    week wk, ww
    weekday dw
    hour hh
    minute mi, n
    second ss, s
    millisecond ms
Sign In or Register to comment.