Need to find day of week then set variable

Hello all!
I'm trying to make sure a variable that is a date, needs to be sun to be set as one way, else any other day another way. 
Here is my code
BEGIN
SELECT CASE WHEN @IssueDate2(WEEKDAY, GETDATE()) = 1
THEN (set @IssueDate3_mjssun= CONVERT(VARCHAR(10),DATEADD(dd, -7, @IssueDate2),101))
ELSE (set @IssueDate3_mjssun= @IssueDate2) END --AS [Last Day]
END
SELECT @IssueDate3_mjssun
I'm open to any other ideas on how to do this.
Thanks!
Rudy

>> I'm open to any other ideas on how to do this. <<
We use CURRENT_TIMESTAMP and not the old Sybase/UNIX getdate() function call.
CASE is an expression; expression return values! You are using it as control flow, like you were writing BASIC or some other procedural language.
CONVERT() is another old Sybase string function. It was used by COBOL programmers who treat temporal data as strings and do display formatting in the program. SQL has temporal data types and we do display formatting in a presentation layer!
We need DDL. This is minimal Netiquette. If you want to be sure that a column is always a Sunday, then use a constraint: CREATE TABLE Foobar (issue_date DATE NOT NULL CHECK(issue_date DATEPART(WEEKDAY, issue_date) = 7, ..); This is another way that columns are not fields, that declarative SQL is not a procedural language.
If you use weeks as part of your business, I would build a calendar table with a ISO-8601 week-within-year format column in addition to the usual Common Era date. This format is 'yyyyWww-d' where yyyy is the year, W is a separator token, ww is (01-53) week number and d is (1-7) day of the week. You input any calendar date, find the week-within-year column and return the dates that match on a LIKE predicate. Ex: WHERE sale_day LIKE '2012W26-[67]'
In the ISO Standards, Sunday = 7. But Microsoft screwed up and had an incorrect default. They then added a kludge that allows you to set schema level parameters
>> I'm open to any other ideas on how to do this. <<
We use CURRENT_TIMESTAMP and not the old Sybase/UNIX getdate() function call.
CASE is an expression; expression return values! You are using it as control flow, like you were writing BASIC or some other procedural language.
CONVERT() is another old Sybase string function. It was used by COBOL programmers who treat temporal data as strings and do display formatting in the program. SQL has temporal data types and we do display formatting in a presentation layer!
We need DDL. This is minimal Netiquette. If you want to be sure that a column is always a Sunday, then use a constraint: CREATE TABLE Foobar (issue_date DATE NOT NULL CHECK(issue_date DATEPART(WEEKDAY, issue_date) = 7, ..); This is another way that columns are not fields, that declarative SQL is not a procedural language.
If you use weeks as part of your business, I would build a calendar table with a ISO-8601 week-within-year format column in addition to the usual Common Era date. This format is 'yyyyWww-d' where yyyy is the year, W is a separator token, ww is (01-53) week number and d is (1-7) day of the week. You input any calendar date, find the week-within-year column and return the dates that match on a LIKE predicate. Ex: WHERE sale_day LIKE '2012W26-[67]'
In the ISO Standards, Sunday = 7. But Microsoft screwed up and had an incorrect default. They then added a kludge that allows you to set schema level parameters
--CELKO-- 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

Similar Messages

  • Determine if today is [day of week], then run action?

    I made a workflow to download a number of comics. Some of them are published every day - let's call them subset A. Some of them are published only on Sundays - let's call them subset B. I'd like to make ONE workflow that:
    1) checks what day of the week it is
    2) if day is Sunday, get A + B
    3) if day is any other day, get A
    I already have a workflow that downloads the images, I just need to know if there's another action out there somewhere that checks the day of the week....

    You can use an AppleScript action to check the day. Insert this in your workflow to determine which actions to run.
    For example:
    on run
    set currentDay to weekday of (get current date)
    if currentDay = Sunday then
    return true
    end if
    return false
    end run
    So now this action will return true or false depending on whether the day is Sunday or not. You can use this as the decision as to whether or not to run the Sunday schedule. A similar script can check for weekdays (or, slightly easier, lack of weekend days):
    on run
    set currentDay to weekday of (get current date)
    if currentDay ≠ Sunday and currentDay ≠ Saturday then
    return true
    end if
    return false
    end run

  • I need to find out how to re-set icloud id on my iphone. I already had an apple id which is a family id. I used it as my id when setting up my new company phone. I have new apple id but can't change icloud phone. Still recognizes old id.

    I have a new company iphone. When setting it up I used a current "family" apple id I created for the children's itouch's. I realized after the fact that all of their contact/content dat is syncing to my business phone. I created a new apple id for the phone,logged out of the old id and in with the new on my phone. However, it will not allow me to make this same change for icloud on the phone. The icloud is still associated to the old id. How can I change my phone icloud to sync with my new apple id and stop getting the kids content?

    In order to change your Apple ID or password for your iCloud account on your iOS device, you need to delete the account from your iOS device first, then add it back using your updated details. (Settings > iCloud, scroll down and hit "Delete Account")

  • Need to find the instruction how to set up with messages

    I need messages (former iChat) manual.

    Hi,
    Messages is iChat+  (Templeton Peck wrote iCal...)
    It still has the Buddy Lists with the AIM  and Jabber Buddies you might have.
    However at first start up the App does tend to require an Apple ID to "register" it for iMessages (the new bit to the app).
    This adds the Apple ID as an Account labled as iMessages in the Messages Menu > Preferences > Accounts
    You can also add other Accounts (Screen Names that are valid with AIM and various Jabber IDs)
    Once you have added your AIM Screen Name then the Buddy list is in the Window Menu > Buddies with the CMD + 1 keystrokes.
    At this point it is a combined list  (Bonjour if Enabled, AIM and Jabber Buddies all in one list)
    GO to the General section of the Preferences and untick the line about gathering all accounts in to one List.
    If you have several Buddy Lists logged in they will now appear separately like they did in iChat.
    A Buddy list can then chat AIM Valid Name to AIM Valid Name.
    AIM valid names can be those Registered at AIM
    Or they can be certain types of Apple ID  (those ending @mac.com and @me.com)
    Obviously this means that your Apple ID may be the iMessages ID and the AIM name you use.
    This will mean entering the ID twice. (As Templeton Peck implies.)
    10:32 PM      Wednesday; October 31, 2012
    Please, if posting Logs, do not post any Log info after the line "Binary Images for iChat"
      iMac 2.5Ghz 5i 2011 (Mountain Lion 10.8.2)
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro 2Gb (Snow Leopard 10.6.8)
     Mac OS X (10.6.8),
     Couple of iPhones and an iPad
    "Limit the Logs to the Bits above Binary Images."  No, Seriously

  • Need to find common number

    Need to find common number among the set of calls :
    Create table call (id number(15) primary key not null , mobile_number number(10), other_party number(10), call_type varchar2(10),call_date_time date, duration number(15));
    insert into call values(1,9818764535,9899875643,'IN',to_date('24-APR-13 02:10:43','dd-MON-yy hh24:mi:ss'),10);
    insert into call values(2, 9897451236,9899875643,'OUT',to_date('28-APR-13 08:11:13','dd-MON-yy hh24:mi:ss'),20);
    insert into call values(3, 9899917277,9899875643,'IN',to_date('30-APR-13 18:07:02','dd-MON-yy hh24:mi:ss'),30);
    insert into call values(4,9818764535,9215478213,'IN',to_date('01-MAY-13 02:11:13','dd-MON-yy hh24:mi:ss'),40);
    insert into call values(5, 9899917277,9215478213,'IN',to_date('01-MAY-13 08:17:02','dd-MON-yy hh24:mi:ss'),25);
    insert into call values(6, 9897451236,9012451785,'OUT',to_date('01-MAY-13 20:21:04','dd-MON-yy hh24:mi:ss'),67);
    Query criteria :
    common caller for list of numbers who is in contact with listed numbers .
    Input Mobile_number:
    9818764535
    9897451236
    9899917277
    output common number
    Mobile number  otherparty date_time duration
    9818764535 9899875643 24-APR-13 02:10:43 10
    9897451236 9899875643 28-APR-13 08:11:13 20
    9899917277 9899875643 30-APR-13 18:07:02 30

    Thanks , it helped
    But if internal calls among these mobile numbers are to be find then
    insert into call values(1,9818764535,9899875643,'IN',to_date('24-APR-13 02:10:43','dd-MON-yy hh24:mi:ss'),10);
    insert into call values(2, 9897451236,9899875643,'OUT',to_date('28-APR-13 08:11:13','dd-MON-yy hh24:mi:ss'),20);
    insert into call values(3, 9899917277,9899875643,'IN',to_date('30-APR-13 18:07:02','dd-MON-yy hh24:mi:ss'),30);
    insert into call values(4,9818764535,9215478213,'IN',to_date('01-MAY-13 02:11:13','dd-MON-yy hh24:mi:ss'),40);
    insert into call values(5, 9899917277,9215478213,'IN',to_date('01-MAY-13 08:17:02','dd-MON-yy hh24:mi:ss'),25);
    insert into call values(6, 9897451236,9012451785,'OUT',to_date('01-MAY-13 20:21:04','dd-MON-yy hh24:mi:ss'),67);
    insert into call values(7,9818764535,9897451236,'IN',to_date('02-MAY-13 22:10:43','dd-MON-yy hh24:mi:ss'),100);
    insert into call values(8, 9899917277,9818764535,'IN',to_date('02-MAY-13 23:07:02','dd-MON-yy hh24:mi:ss'),130);
    Input Mobile_number:
    9818764535
    9897451236
    9899917277
    output internal calls :
    Mobile number otherparty call_type date_time duration
    9818764535 9897451236 IN 02-MAY-13 22:10:43 100
    9899917277 9818764535 IN 02-MAY-13 23:07:02 130

  • Find and Replace more then one character

    Hi
    I need to find and replace more then one character. for example: I need to replace "A" with "a". "B" with "b" and so on. how to do that in one search?

    See the following script by Peter Kahrel:
    Change case
    http://www.kahrel.plus.com/indesign/grep_change_case.html
    If the "A" and the "B" are in arbitrary positions in your text you could use the following GREP:
    [AB]
    together with the script.
    For testing your GREP expressions, you could use the following script, also by Peter Kahrel:
    A GREP editor
    http://www.kahrel.plus.com/indesign/grep_editor.html
    Uwe

  • Need to find a calendar to schedule multiple assignments with multiple tasks set on specific days for multiple people

    There may be no such animal as what I am searching for, but I thought I'd give it a try.
    What I need to do is find a calendar app that allows me to have individual calendars for staff members that I can place a several-days-long assignment and have those people access remotely on an iPad or iPhone (autosync).
    I also want to be able to have tasks set on specific days within that assignment that have alerts/reminders for each stage of the assignment.
    Being able to custom colour each individual assignment (not just the person's own calndar) is also necessary, as these asignments overlap and need to be easily distinguishable at a glance. Each assignment needs to be its own entity and not affect any furture or previous entries, even if I choose the same colour.
    It needs to be in a month by month view and be able to be something each person can subscribe to and sync up with for changes on a daily basis. It does nothave to be a calendar like in the screen shot below, it could be a linear calendar that has days across the top and assignments down the left side.....
    Here is a screen shot of a rudimentary excel spreadsheet I have been using. It is awkward and becoming unmanageable as the number of assigments increases and more staff are being added on. And I must send a new spreadsheet out every time I make a change or add an assignment, which is several times a week.
    I suspect I may be asking for the world, but if anyone knows a direction I can go in to start a search, I'd be grateful. I haven't had success of my own so far and need to find something soon.
    iCal doesn't work for me due to the fact I can only colour code the calendar itself and not the event, plus not being able to have multiple tasks within one event. And the qty of assignments I'd have would see most getting lost, eliminating my abilty to see every staff member's assignmanet at the same time.
    Thank you in advance if you have a suggestion and if not, thanks for looking at my dilemma! 

    check with T-code TPM44
    zashok

  • I am trying to get my computer to print on HP C310.  It was working fine until 2 days ago and then stopped printing. I thought I could uninstall the HP software and download it again comes to find that I cannot now use the disk supplied with the printer.

    I am trying to get my computer to print on HPC310.  It was working until 2 days ago and then stopped working.  I uninstalled the HP software thinking I could just reinstall and it would help but I cannot now install that software from the disk.  How do I go about getting the old software I had on the computer and how do I get my computer to print.  It gives my messages that it cannot find the printer or printer unknown.

    Your operating system, Snow Leopard (OS X 10.6), does not support AppleTalk. Instead, in Snow Leopard the HP 4000 series printers need to be set up to communicate via IP.
    Go to System Preferences and open the Print & Fax item. Is your printer listed in that pane?

  • SelectInputDate set first day of week

    Hi all! I was trying to change the first day of week showed in the calendar (Ex. set the first day the Monday) but i dont find any results :(
    Someone know how to change it?
    Many thanks.
    Jose.

    Hi Jose, <br>
    <br>
    Unfortunately, this is not possible in JDeveloper 10.1.3<br>
    See "<a href="http://blogs.oracle.com/Didier/2007/02/26#a218"> Setting the First Day of the Week to Monday in the SelectInputDate component</a>" for more details. <br>
    <br>
    Regards, <br>
    <br>
    Didier.<br>
    <br>

  • Query for getting Last 4 Day of weeks - need help

    I am having a table profile that contains a column 'Modified_Date' that stores date values. The table contains records for the last one month.
    Now, I need a query that gives me the last 3 wednesdays (Including today)
    i.r,. I need the last 4 wednesdays including today.
    How can I acheive this.
    Thanks in advance.
    Regards
    Raghu.

    Hi,
    explain? I'll try.
    Level is a pseudocolumn used in conjunction with connect by. In connect by I used < 5 as a condition since you wanted the last 4 Wednesday. I used it to get a number to be used as a multiplier.
      1  select next_day(sysdate,'wednesday')-(7*level) weds, level lvl from dual
      2* connect by level < 5
    SQL> /
    WEDS             LVL
    06-AUG-08          1
    30-JUL-08          2
    23-JUL-08          3
    16-JUL-08          4
    next_day(p_date,'wednesday') returns the calendar date of Wednesday after the date in p_date
    (7*level) a week is composed of seven (7) days multiplied by level or number of weeks to get number of days between weeks. I then subtract this from the result of next_day function

  • Needing to find email setting

    Hi Im brand new to the mac system I have now and I have a question. I need to find my email settings for .mac account. but I have no idea where to look. I want to set up an account on My entourage and dont have the needed info. can anyone help oh NAd Im not sue as to what operating system I have so if that makes a difference then Ill need help with that

    You can find your emal account settings by launching Mail, then go to Preferences->Accounts and you can see them there for each account.
    Mulder

  • In what file is my former email stored or do I need to set this up? I need to find an email I was sent 12/29/2010.

    I need to find an email I received 12/29/2010. How do I find my email archive? I am assuming one is automatically set up in Apple OS... or do I need to set that up myself? If so, what is best way to set it up and transfer read/written mail to it? Help!!! Thank you!!!

    Mail->Mailbox->New Smart Mailbox, and enter:

  • Screen freezes and popup message says I need to do a shutdown and then restart.  It does it sometimes 2 times a day. Im new to apple and need help.

    My screen freezes and popup message says I need to do a shutdown and then restart.  It does it sometimes 2 times a day. Im new to apple and need help.

    Bad or incompatible RAM is, more often then not, the cause of most Kernel Panics. It could also just need to be reset.
    Here's the most used site for Resolving Kernel Panics. Please do all the steps in order, even if you don't think you need to do a certain step.
    Here is a great MacFixIt article.
     Good Luck!
    DALE

  • TS1538 Every time I want to sync my iphone to itunes I have to uninstall and reinstall itunes on my pc. It will only ever find the phone once, then I need to go through this all over again.

    Every time I want to sync my iphone to itunes I have to uninstall and reinstall itunes on my pc. It will only ever find the phone once, then I need to go through this all over again.
    How can I solve this?

    You'll have to do it by process of elimination. Sign into the iTunes Store through the App Store app, go to the Purchased section, and look at the list of apps purchased through your own Apple ID. Anything on your iPhone not in that list isn't yours and should be deleted. The same process would apply to content from the iTunes Store.
    Or you can just restore the iPhone from your most recent backup and then redownload everything from the iTunes Store. But if you have a lot of apps or content, that obviously wlll be slow.
    I updated my iphone by his ID , is it still problem?
    That's probably how you got your friend's purchases. It won't be an issue for iOS, but it is an issue for those apps and content.
    Regards.

  • I need to find out if SMS Messaging can turn on automatically when my Ipad receives an Update or does a Password have to be entered to do this?  IE, when my IPAD SMS is turned on then my Iphone messages can be accessed.

    I need to find out if SMS Messaging can turn on automatically when my Ipad receives an Update or does a Password have to be entered to do this?  IE, when my IPAD SMS is turned on then my Iphone messages can be accessed.

    Maybe I used the wrong term for it.  Basically, someone recently had my Ipad and somehow turned on my messaging so they could read all of the messages on my Iphone.  I would think this the password was used to do this however they advised that the Ipad had an update which then activated the messaging.  Can this happen?

Maybe you are looking for

  • Reading strings and integers from a text file

    I want to read the contents of a text file and print them to screen, but am having problems reading integers. The file contains employee's personal info and basically looks like this: Warren Laing 32 //age, data type is int M //gender, data type is S

  • Problems assigning BP to a position in the organizational structure

    I tried to assign a bp to a position in the organizational structure, but I receive this message "Object cannot be assigned to object CliC Agent in the period 21.12.2006 - 31.12.9999". Also, I notice that in the screen, the checkbox where i can selec

  • Retrieving a message id

    Hello I am planning to retreive message id into my mappings program.I used a simple Java Function for the same.My code looks like *******************code********************** java.util.Map = container.getTransformationParameters(); String mid = (Str

  • Random Message implants into messages as I type them????

    I keep getting this message implanted into messages that I type about 25% of the time. I have gone through my saved messages and do not find that set of directions. This is from an area I am kinda familiar with but have no clue why it inserts itself.

  • How to make a chart/graph of text?

    Trying to make a chart of "Causes of Death" from a database of people to see how many people died of each cause. I have a standard database with names listed vertically, and categories (last name, first name, age, cause of death, etc.) horizontally.