IDE + date() = ParseDate

  1. If I run my app and there is an error, the program stop, show me the error in the IDE…
    Then, when I press “stop” the IDE show me the last code where I worked with, not the code with the error.
    I find this very annoying because my short term memory is slippery and I always forget where the error is, because it’s just in front of me…

Jakob - when the error occurs, and you are presented with the debugger - simply press the button which has a pencil as its icon, and you will be taken to the line of code which needs to be corrected automatically :slight_smile:

Thank’s I’ll try that!

  1. How do I convert the SQLDateTime to the more convenient YYYY-MM-DD format??

[code] IF rs <> NIL THEN
while not rs.eof
DIM strCreated as string = rs.Field(“dteCreated”). StringValue
lstBatch.AddRow(strCreated.ShortDate )

rs.MoveNext WEND[/code]

use SQLDate with out time or you need the time

Hmm…
This is not the answer I was expecting!

I used to have two fields, dteCreatedDate, dteCreatedTime to solve the issue, just as you point out.

But now I think, it’s kind of silly to use two columns for the same purpose.

If you are familiar with Microsofts Active Server Pages, ASP:

<% dteCreated = now() response.write formatDateTime(dteCreated, 1) %>

[quote]vbGeneralDate |0 | Display a date and/or time. If there is a date part, display it as a short date. If there is a time part, display it as a long time. If present, both parts are displayed.

vbLongDate | 1 | Display a date using the long date format specified in your computer’s regional settings.
vbShortDate | 2 | Display a date using the short date format specified in your computer’s regional settings.
vbLongTime |3 | Display a time using the time format specified in your computer’s regional settings.
vbShortTime | 4 | Display a time using the 24-hour format (hh:mm).
[/quote]
(I don’t know where on Internet this is documented, I have a small software as I use…)

Never mind.
The point is, I may use it in the future, in other situations, so to be on the safe side I’d like to use the long date. Just in case!

This works! Thank you!
ParseDate it is! :slight_smile:
http://documentation.xojo.com/index.php/ParseDate

[code]

dim d as new date
dim strDate as string
strDate = str(d)

DIM bolDteConverted as Boolean
DIM newDate as date

bolDteConverted = ParseDate(strDate, newDate)

If bolDteConverted = TRUE then
MsgBox str(newDate) + " Converted to: " + newDate.LongDate + " == " + newDate.ShortDate + " == " + newDate.ShortTime
'MsgBox("Converted to: " + newDate.ShortDate)
Else
MsgBox(“Could not convert the string to a date.”)
End If[/code]

Here’s my code, for the record, for the documentation, for others to use:

For all of you that fear American style dates! Here’s how to avoid it.

[code] IF blnResult = TRUE THEN
’ ## READ FROM DB
dim sql as string

' ## QUESTION
'sql = "SELECT intID, dteCreatedDate, dteCreatedTime FROM [KATBatch]  ORDER BY dteCreatedDated"
sql = "SELECT intID, dteCreated, intTotalScore FROM [KATBatch] ORDER BY dteCreated DESC "

dim rs as RecordSet = dbDatabase.SQLSelect(sql)

' ## FILL DATA
IF rs <> NIL THEN
  while not rs.eof
    DIM strDate As String =  rs.Field("dteCreated"). StringValue 
    DIM newDate as date
    DIM bolDate As Boolean = ParseDate(strDate, newDate)
    IF bolDate = TRUE THEN
      lstBatch.AddRow( newDate.ShortDate )
    ELSE
      lstBatch.AddRow( "no date" )
    END IF
    'lstBatch.AddRow( rs.Field("dteCreated"). StringValue )
    lstBatch.Cell(lstBatch.LastIndex,1) =  rs.Field("intTotalScore").StringValue
    
    lstBatch.RowTag(lstBatch.LastIndex) = rs.Field("intID"). StringValue

    rs.MoveNext
  WEND
 
END IF

END IF[/code]