Results 1 to 2 of 2

Thread: SELECT CONVERT syntax?

  1. #1
    Join Date
    Dec 1969

    Default SELECT CONVERT syntax?

    hello,<BR><BR>i have an sql statement reading like this:<BR><BR>SQL = "SELECT * FROM tbl_ACD_Data_Report_4 WHERE postdate Between &#039;" & begin_date & "&#039; And &#039;" & end_date & " AND Time Between &#039;" & begin_time & "&#039; And &#039;" & end_time & "&#039; ORDER BY postdate, Time"<BR><BR>i&#039;m unable to do the between statement on the Time field. I checked the variable type and, sure enough, the Time field in the database is coming out as a string, not a date/time (even though the Time field is listed as a date/time type field).<BR><BR>so, anyway, i saw that you can do something like this: "select convert" and i was hoping that might solve my problem. i could convert the Time field and then do the between statement.<BR><BR>does anyone know the syntax i need to use here? or can someone suggest another solution?<BR><BR>thanks<BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: SELECT CONVERT syntax?

    Mapping date or time Data<BR>Because C does not have a date or time data type, Microsoft® SQL Server™ date or time columns are converted to characters by using the SQL Server default date format, for example:<BR><BR>mm dd yyyy hh:mm:ss[am &#124 pm]<BR><BR>You can send dates to SQL Server from C character fields by using any of the character date formats accepted by SQL Server. For a date without a time, use an 11-byte receiving field. If data is truncated, the SQLWARN3 field of the SQLCA data structure is set. For other formats, use the Transact-SQL CONVERT statement. For example, to convert a time without a date, use a statement similar to this:<BR><BR>SELECT CONVERT(char, date, 8) FROM sales<BR><BR> <BR><BR>When you attempt to put a fixed-length data type into a buffer that is too small for it, an error occurs and no data is copied.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts