To set the quarter date according to the date flag.

  • Below is the following condition :-

    select QuarterDate,sf_115,sf_315,sf_415,sf_515,sf_615,sf_915

    ,sf_1015,sf_1115,sf_1215

    from EstimatedData

    QuarterDatesf_115sf_315sf_415sf_515sf_615sf_915sf_1015sf_1115sf_1215

    15-01-2015 1 NULL NULL NULL NULL 1 NULL 1 NULL

    15-12-2015 NULL NULL NULL NULL NULL NULL NULL NULL 1

    30-09-2015 NULL 1 NULL 1 NULL 1 NULL 1 NULL

    The sf_115,sf_315.. etc

    where sf_115 flag is for 15th of the 1st month, sf_315 flag is for 15th of the 3rd month

    Since the quarter date of the first data is 15-01-2015, so when the date will go for rollover and the sf_915 flag is set, then the quarter date will get set as 15-09-2015. The date will be set as the next date according to the flag.

    Since the quarter date of the second data is 15-12-2015, so when the date will go for rollover and sf_1215 flag is set then the quarter date will get set as 15-12-2016 i.e the date will be set of the next year.

    Since the quarter date of the third data is 30-09-2015, so when the date will go for rollover and then the date till get set as 15-11-2015.

    So can u tell me how to build the logic.

    Thanks,

    Sushil Kushwaha

  • You'll need to be a bit more clear.

    Can you provide sample data, desired output and table DDL?

    "date will go for rollover" --> what do you mean with this?

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • On the front end there will be rolllover button. when the user click the rollover button by checking the check box and submit.

    then the date will be converted according to the flag to the next date.

    Thanks

    Sushil Kushwaha

  • no input, just consumable data to help:

    ;WITH EstimatedData([QuarterDate],[sf_115],[sf_315],[sf_415],[sf_515],[sf_615],[sf_915],[sf_1015],[sf_1115],[sf_1215])

    AS

    (

    SELECT CONVERT(DATETIME,'01-15 -2015'),'1',NULL,NULL,NULL,NULL,'1',NULL,'1',NULL UNION ALL

    SELECT '12-15-2015',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'1' UNION ALL

    SELECT '09-30-2015',NULL,'1',NULL,'1',NULL,'1',NULL,'1',NULL

    )

    SELECT QuarterDate,

    sf_115,

    sf_315,

    sf_415,

    sf_515,

    sf_615,

    sf_915,

    sf_1015,

    sf_1115,

    sf_1215

    FROM EstimatedData

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply