Romio_1968
Member
- Local time
- Today, 08:30
- Joined
- Jan 11, 2023
- Messages
- 126
I have a table containing a Date/Time field
The system date format is "dd-mm-yyyy"
A weird thing happends
If i am using Now() function to add a date value in the table using SQL, the month and day are inverted
Example 1>
Example 2
In all tables, if i try to use Now(), the d-m inversion occurs
Yet, if I have a control form with default value set to Now(), the value is passed corectly, so the system formats seems to work
it occurs only by using SQL statements
The system date format is "dd-mm-yyyy"
A weird thing happends
If i am using Now() function to add a date value in the table using SQL, the month and day are inverted
Example 1>
Code:
' Add 3 consecutive records in "TDJunction" table
Dim db2 As DAO.Database
Dim rs2 As DAO.Recordset
Set db2 = CurrentDb
Set rs2 = db2.OpenRecordset("TDJunction")
For i = 1 To 3
If Me("Rank" & i) <> 0 Then
rs2.AddNew
rs2!Title_IDFK = Me.Title_ID
rs2!ClassCode_FK = Me("ClassCode" & i)
rs2!Rank = Me("Rank" & i)
rs2!Timestamp = Now()
rs2.Update
End If
Next i
Example 2
Code:
Public scrapTmstp As Date
(...)
'Form_Load event
scrapTmstp = Now()
(...)
'Click Event
' Insert a new record into the "ScrappedInventory" table with the same Inventory_No, Title_ID, and current timestamp
strSQLscrap = "INSERT INTO ScrappedInventory (Inventory_No, Title_IDFK, ScrapTimestamp, AddTimestamp) " & _
"VALUES (" & invNo & ", " & titleID & ", #" & scrapTmstp & "#, #" & addTmstp & "#)"
db.Execute strSQLscrap
In all tables, if i try to use Now(), the d-m inversion occurs
Yet, if I have a control form with default value set to Now(), the value is passed corectly, so the system formats seems to work
it occurs only by using SQL statements