hi guys i am puting this query in my querybuilder in the table adapter but i need to make the query only return
the transaction done today!! i dont know the syntax to get the cuurent date today. this query should work in the tableadapter query configuration wizard!!!

SELECT        Trans_ID, Trans_Cash, Trans_Deposit, Trans_Mtc, Trans_Alfa, Trans_Desc, Trans_Delete_Flg, Trans_Date, Trans_User_Name, Trans_Admin_Flg, 
                         Trans_Msg_Cost
FROM            Transactions
WHERE        (Trans_Admin_Flg = FALSE) AND (Trans_Date >= .....?????

thanks for the help

Recommended Answers

The current date in MySQL can be used with the curdate function. In MS SQL use GETDATE (returns date and time). so thelast part of your SQL statement should be

Trans_Date >= CURDATE()) or
Trans_Date >= GETDATE())

You can find out plenty more options on either …

Jump to Post

All 3 Replies

The current date in MySQL can be used with the curdate function. In MS SQL use GETDATE (returns date and time). so thelast part of your SQL statement should be

Trans_Date >= CURDATE()) or
Trans_Date >= GETDATE())

You can find out plenty more options on either the MySQL reference site or MSDN for whichever database you are using.

Keep in mind that in MSSQL, GETDATE() returns a datetime value so the comparison

trans_date >= GETDATE()

will fail if trans_date is not stored as a datetime field or trans_date is in the current day but earlier in the day. To do a proper comparison you would have to take the date part only of GETDATE and compare against that.

The SQL date functions will pull the date from the computer acting as the DB server. It may not be appropriate to use the server's date for the comparison unless it is also used to set the transaction date field.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.