Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Date Field Comparisions Expand / Collapse
Author
Message
Posted Friday, December 21, 2012 9:22 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Tuesday, October 8, 2013 5:13 AM
Points: 67, Visits: 269
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


  Post Attachments 
untitled.bmp (14 views, 445.29 KB)
Post #1399485
Posted Friday, December 21, 2012 9:40 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 11:26 AM
Points: 13,436, Visits: 12,299
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 Moden's 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)
Post #1399497
Posted Friday, December 21, 2012 2:03 PM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Today @ 6:38 AM
Points: 1,945, Visits: 3,001
Please post DDL, so that people do not have to guess what the keys, constraints, Declarative Referential Integrity, data types, etc. in your schema are. If you know how, follow ISO-11179 data element naming conventions and formatting rules. Temporal data should use ISO-8601 formats. Code should be in Standard SQL as much as possible and not local dialect.

This is minimal polite behavior on SQL forums.

Sample data is also a good idea, along with clear specifications. It is very hard to debug code when you do not let us see it. We do not like to look at pretty colored pictures; they do not not compile. Actually, nobody like to open attachments from strangers.


Books in Celko Series for Morgan-Kaufmann Publishing
Analytics and OLAP in SQL
Data and Databases: Concepts in Practice
Data, Measurements and Standards in SQL
SQL for Smarties
SQL Programming Style
SQL Puzzles and Answers
Thinking in Sets
Trees and Hierarchies in SQL
Post #1399588
Posted Thursday, October 17, 2013 12:15 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Saturday, November 16, 2013 2:05 AM
Points: 17, 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
Post #1505493
Posted Thursday, October 17, 2013 1:28 AM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Today @ 8:08 AM
Points: 23,396, Visits: 32,224
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.



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)
Post #1505504
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse