SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Date Field Comparisions


Date Field Comparisions

Author
Message
sqlfriends@sql.com
sqlfriends@sql.com
SSC-Enthusiastic
SSC-Enthusiastic (102 reputation)SSC-Enthusiastic (102 reputation)SSC-Enthusiastic (102 reputation)SSC-Enthusiastic (102 reputation)SSC-Enthusiastic (102 reputation)SSC-Enthusiastic (102 reputation)SSC-Enthusiastic (102 reputation)SSC-Enthusiastic (102 reputation)

Group: General Forum Members
Points: 102 Visits: 280
Hi Experts

I have the clarification in date comparision in previos dates , in One condition need To check Where my Typ_id is 01 and 02 Then date can be Applied the below logic Or else
Date can be updated in Previous Dates

Typ_id logic

First_date < Second_date The condition is True then We need to compare the Second_date corresponding the First_date columns is greater then than we updated the First_date Else Second_date updated

Find the Attachment
Attachments
untitled.bmp (17 views, 445.00 KB)
Sean Lange
Sean Lange
One Orange Chip
One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)

Group: General Forum Members
Points: 26000 Visits: 17528
sqlfriends@sql.com (12/21/2012)
Hi Experts

I have the clarification in date comparision in previos dates , in One condition need To check Where my Typ_id is 01 and 02 Then date can be Applied the below logic Or else
Date can be updated in Previous Dates

Typ_id logic

First_date < Second_date The condition is True then We need to compare the Second_date corresponding the First_date columns is greater then than we updated the First_date Else Second_date updated

Find the Attachment


Can you try to clarify what you are doing? I can't understand the logic here. Also, it will be helpful if you can post ddl, sample data and desired output. Please see the first link in my signature for best practices when posting questions.

_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Modens splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
shobanapraveen
shobanapraveen
SSC Rookie
SSC Rookie (33 reputation)SSC Rookie (33 reputation)SSC Rookie (33 reputation)SSC Rookie (33 reputation)SSC Rookie (33 reputation)SSC Rookie (33 reputation)SSC Rookie (33 reputation)SSC Rookie (33 reputation)

Group: General Forum Members
Points: 33 Visits: 46
Hi Friends,

Can any one help me in calculating past N hrs,past week,past7days,pastNdays,past2weeks,past14days,this month. Date should be compare with today and should automatically calculate the selected date.


Thanks,
Shobana
Lynn Pettis
Lynn Pettis
SSC-Dedicated
SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)

Group: General Forum Members
Points: 39213 Visits: 38529
shobanapraveen (10/17/2013)
Hi Friends,

Can any one help me in calculating past N hrs,past week,past7days,pastNdays,past2weeks,past14days,this month. Date should be compare with today and should automatically calculate the selected date.


Thanks,
Shobana


First, you really should post new questions in a new thread.

Second, based just on your post, I am not sure what you are trying to accomplish.

Cool
Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search