473,396 Members | 2,036 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Formatting a Date if already using MIN function

I have a query where I am using the MIN function to filter out duplicate Call Numbers (Call_No). The query works well and returns 34 records -- perfect. Here it is:

Expand|Select|Wrap|Line Numbers
  1. SELECT RV_CALL_HISTORY.Call_No as "Call Number",
  2. MIN(RV_CALL_HISTORY.Call_Log_Date) as "Call Log Date",
  3. MIN(RV_CALL_HISTORY.Call_Hist_Date) as "Call Hist Date"
  4. FROM RV_CALL_HISTORY
  5. WHERE
  6. RV_CALL_HISTORY.Call_Log_Date > '2012-04-01 00:00'
  7. AND
  8. RV_CALL_HISTORY.Call_Hist_Action_Officer='Joe Blow'
  9. AND
  10. RV_CALL_HISTORY.Call_Log_Date < GETDATE()
  11. GROUP BY RV_CALL_HISTORY.Call_No
---------------------------
Now I would like to convert the Call_Hist_Date to:
YYYY.MM.DD

I have tried using the following, but then I lose the filter. I get 114 records:
Expand|Select|Wrap|Line Numbers
  1. SELECT RV_CALL_HISTORY.Call_No as "Call Number",
  2. MIN(RV_CALL_HISTORY.Call_Log_Date) as "Call Log Date",
  3. CONVERT(VARCHAR(10),RV_CALL_HISTORY.Call_Hist_Date,102) as [YYYY.MM.DD]
  4. FROM RV_CALL_HISTORY
  5. WHERE
  6. RV_CALL_HISTORY.Call_Log_Date > '2012-04-01 00:00'
  7. AND
  8. RV_CALL_HISTORY.Call_Hist_Action_Officer='Joe Blow'
  9. AND
  10. RV_CALL_HISTORY.Call_Log_Date < GETDATE()
  11. GROUP BY RV_CALL_HISTORY.Call_No,RV_CALL_HISTORY.Call_Hist_Date
-------------------------
Any idea how I can combine the MIN and CONVERT functions?
I am using Microsoft SQL Management Studio (Microsoft SQL Server 2008 R2)

Thanks,
skifast
Apr 17 '13 #1
1 1469
Rabbit
12,516 Expert Mod 8TB
Please use code tags when posting code.

Do the conversion around the min.
Apr 18 '13 #2

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

Similar topics

2
by: Bill | last post by:
I'm currently entering the date into my date field using the now() function, which delivers this result: 2/2/2004 9:08:09 AM which is fine for some cases. However, when retreiving this result,...
3
by: Bruno BAGUETTE | last post by:
Hello, I'm looking for a way to convert a unix timestamp to a PostgreSQL date without using ::abstime which seems to be deprecated. Currently, I do that query : levure=> select...
1
by: Mike | last post by:
In C, we can typedef pointer to functions, and therefore use function tables. But what's the advantage of using function table? Thanks, Mike
1
by: George LAZAR | last post by:
how can I change the system current date (time) using c#? thank you George
0
by: Alen Hubtka | last post by:
Hello All, Can any one share the code to compare two date data using Java script?Please. I would like to compare two dates and findout there are greater than or less than each other. Thanks,...
3
by: natin | last post by:
Hi How do i display a date field using databind.eval ?
0
by: hemant123 | last post by:
Hi I Am Trying To Insert Null Value In Oracle Date Column Using Visual Basic 6 Textbox. I Tried Various Options But Unable To Insert. Please Advise Me A Solution. Thanks In Advance Hemant
3
by: drsantosh82 | last post by:
Hi, I am trying to implement a callback routine using function pointers. Basically, I am trying to avoid tying my callback invoking member to a particular class. Let me explain my problem...
2
by: John Smith | last post by:
Hello, I have a VB.NET application with a Windows form that have several textboxes fields where I have dates entered. I would like to do a date validation check after the the field is updated, so...
1
by: Charly O | last post by:
What is the best way to validate a TextBox for Date input using VBA. How to code date inputmask in vba
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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,...
0
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...

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.