473,624 Members | 2,651 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

problem in comparing date

375 Contributor
Hi,

I have designed an employee portal. The moment the user logs in and logs out the current datetime will be stored.
Before the user logs out I should ensure whether he/she has entered the work done form for that day.

I wrote
select count(*) from workdone where work_date_time= getdate()
If there are any rows that means he/she has filled up the form else not filled.

But the query is comparing the date as well as time.
I want to compare only the date.
How should I reframe the query

Regards
cmrhema
Dec 2 '07 #1
1 1221
Jim Doherty
897 Recognized Expert Contributor
Hi,

I have designed an employee portal. The moment the user logs in and logs out the current datetime will be stored.
Before the user logs out I should ensure whether he/she has entered the work done form for that day.

I wrote
select count(*) from workdone where work_date_time= getdate()
If there are any rows that means he/she has filled up the form else not filled.

But the query is comparing the date as well as time.
I want to compare only the date.
How should I reframe the query

Regards
cmrhema

SQL Server stores dates and time together. Depending on your application and how you are passing your date parameter in as part of your where clause (ie which part of the world you are in) you need to be mindful of your regional settings and look at the CONVERT function in SQL Server

SELECT CONVERT(char(10 ), GETDATE(), 103)

Will return getdate as character conversion based on the UK regional setting (103)

Regards

Jim :)
Dec 3 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

16
13115
by: Donnal Walter | last post by:
I was very surprised to discover that >>> import datetime >>> x = datetime.date(2004, 9, 14) >>> y = datetime.datetime(2004, 9, 14, 6, 43, 15) >>> print x == y True How can these two objects be considered equal? Is there a *general* way to test for date != datetime as well as 4.5 != 4.6?
19
7270
by: Lauren Quantrell | last post by:
I have a stored procedure using Convert where the exact same Convert string works in the SELECT portion of the procedure but fails in the WHERE portion. The entire SP is listed below. Specifically, I have a problem with this portion in the WHERE clause: DATEADD(Day,tblMyEventTableName.ReminderDays, @DateNow) Between CONVERT(smalldatetime,str(DATEPART(Month, @DateNow)+1) + '/' + str(DATEPART(Day, tblMyEventTableName.TaskDateTime)) + '/'...
1
1814
by: E. Liepins | last post by:
I am working on a vehicle database. We track when a vehicle is borrowed and when it is returned. We also track the number of kilometres travelled on a particular trip. There are several tables: tblLeaders - lists the people, tblVehicle, tblresults - where the info is stored for trips, tblVehicleType- we charge different rates for different types of vehicles. We have 2 main forms frmSignout and frmReturn. My problem occurs when I...
5
4276
by: rjfjohnson | last post by:
Hey, Today is Thursday 16-Feb-06. The same thursday last year is 17-Feb-05. Because I am comparing daily sales between years, I need to know the date of the same weekdayname as last year, so that I am comparing Saturdays with Saturdays, Sundays with Sundays, etc ie, 16-feb-06 goes to 17-feb-05 28-july-06 goes to 27-july-05 and so on
1
6525
by: G Gerard | last post by:
Hello I am having some problem comparing dates with the SQL statement below MySQL = "SELECT Format(Date, 'yyyy/mmmm/dd') as FROM TblDates WHERE _ Format(Date, 'yyyy/mmmm/dd') = #2006/April/18#" Even though the date 2006/April/18 is in TblDates, it is never found by the
2
1399
by: Bob | last post by:
Hi, I have a wrong result when testing today against a date fetched from a table in excel. The value in excel is: 14/12/2006 (european format). When today is after that value in excel, the message "time is over" must appear, otherwise nothing. My problem is that the message appear already when today = that value. Any idea why?
2
3379
by: Pugi! | last post by:
hi, I am using this code for checking wether a value (form input) is an integer and wether it is smaller than a given maximum and greater then a given minimum value: function checkInteger(&$value, $checks) { $err = ''; if (!is_numeric($value) || (floatval($value) != intval($value))) { $err .= 'Input must be an integer. ';
4
7403
by: anagai | last post by:
I just want to check if a date entered in a textbox is equal to the current system date. I set the date object from the input field like this: dt1=new Date('10/01/2007'); the current system date is retrieved like this: curDt = new Date();
1
1866
by: cdhaynes | last post by:
Hi, I am using unbound text boxes in the header of a form to allow the user to search on a number of fields. I am using VBA to build a query string based on these and it has been fine when comparing text fields on the main form but I have run in to trouble comparing date/time fields on a subform. The subform is called Activity and I am comparing to the date/time field ActivityStartDate. This is the code: If Not IsNull(Me.searchFromDate)...
0
8249
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8179
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8493
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7176
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6112
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5570
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4187
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1797
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1493
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.