[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 328
  • Last Modified:

Select all records for one day.

I looking to return only records you the current date with out any user input
Access has a DATE() function. Not sure what to use in SQL
0
dagga007
Asked:
dagga007
  • 2
  • 2
  • 2
  • +1
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
sql server is getdate()

0
 
Aneesh RetnakaranDatabase AdministratorCommented:
You can use  GETDATE () instead of DATE()
0
 
dagga007Author Commented:
Should the getdate() return all records for todays date?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
Aneesh RetnakaranDatabase AdministratorCommented:
No, getdate stores the current date + current time


SELECT CONVERT(varchar(10),GETDATE(),101) -- mm/dd/yyyy
SELECT CONVERT(varchar(10),GETDATE(),103) -- dd/mm/yyyy
0
 
dagga007Author Commented:
Not sure i follow, I think that i'm on the wrong track.

 I'm looking to return all record for one day with out any user input.
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
this will give you all the records of today ( replace the yourtable and yourfield by the correct names):
select * form yourtable
where yourfield >= convert(datetime, convert(varchar(10), getdate(), 120), 120)
and yourfield < dateadd(day, 1, convert(datetime, convert(varchar(10), getdate(), 120), 120))

this will give you all the records of the last 24 hours:
select * form yourtable
where yourfield >= dateadd(day, -1, getdate())
and yourfield < getdate()
0
 
imrancsCommented:
Select * From YourTable Where Convert(Varchar, DateColumn, 101) = Convert(Varchar, GetDate(), 101)

Imran
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 2
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now