Nearest Monday from a given date - how do I do this?

Hello:
We have a requirement to find the nearest Monday from a given date.
Can anyone help me with this query?
Thanks!

This?
  1  with t as (select trunc(sysdate)-3 + level dt
  2  from dual connect by level <=20
  3  )
  4  select dt,round(dt,'iw') nearest_monday
  5* from t
SQL>/
DT                   NEAREST_MONDAY
Sunday    19/09/2010 Monday    20/09/2010
Monday    20/09/2010 Monday    20/09/2010
Tuesday   21/09/2010 Monday    20/09/2010
Wednesday 22/09/2010 Monday    20/09/2010
Thursday  23/09/2010 Monday    20/09/2010
Friday    24/09/2010 Monday    27/09/2010
Saturday  25/09/2010 Monday    27/09/2010
Sunday    26/09/2010 Monday    27/09/2010
Monday    27/09/2010 Monday    27/09/2010
Tuesday   28/09/2010 Monday    27/09/2010
Wednesday 29/09/2010 Monday    27/09/2010
Thursday  30/09/2010 Monday    27/09/2010
Friday    01/10/2010 Monday    04/10/2010
Saturday  02/10/2010 Monday    04/10/2010
Sunday    03/10/2010 Monday    04/10/2010
Monday    04/10/2010 Monday    04/10/2010
Tuesday   05/10/2010 Monday    04/10/2010
Wednesday 06/10/2010 Monday    04/10/2010
Thursday  07/10/2010 Monday    04/10/2010
Friday    08/10/2010 Monday    11/10/2010

Similar Messages

  • How to get period date of for a given month from a given date in mdx for SSRS report (mm/dd/yyyy)

    I have a situation,  where i need to write expression Period to date(PTD). i want to know how to get the period date. i want you to help in writing Period date or else is there any function to get period date for a given date(the  date is given
    from the parameter dynamically) in MDX for SSRS report
    ram

    Hi ram,
    Per my understanding that you want to get the period date based on the month selected and the given date, right?
    Could you please provide details information below to help us better understanding your requirements, thus we will be more effective to provide an solution:
    What is the format of the period date you want to get, is this date in the DB and you want to filter it based on the month and the given Date?
    Did the month and given date are two parameters in the report? if possible, could you please provide some sample data in the DB and also the snapshot of the report structure
    I assume you want to get the period date(mm/dd/yyy) between the select month(e.g:Feb) and the given date (10/1/2014) and you should get the date between(02/01/2014-10/1/2014).
    If so,and you also have two parameter "Month","EndDate"(EndDate is the given date), please reference to details information below:
    You can create an new parameter "BeginDate" (Date/Time) which is the begin date of the period, you can use the expression to get the value based on the value of the month and the year value from the given date,finally hide this parameter:
    Specify the available value:
    Label:=Parameters!Month.Value &"/01/"& DatePart("yyyy",Parameters!EndDate.Value)
    Value:=CDate(=Parameters!Month.Value &"/01/"& DatePart("yyyy",Parameters!EndDate.Value))
    Specify the default Value:
    Value:=CDate(=Parameters!Month.Value &"/01/"& DatePart("yyyy",Parameters!EndDate.Value))
    Add filter to the dataset as below:
    Preview you will get all the date in the given Period:
    If you still have any problem, please feel free to ask.
    Regards
    Vicky Liu

  • From two given tables, how do you fetch the values from two columns using values from one column(get values from col.A if col.A is not null and get values from col.B if col.A is null)?

    From two given tables, how do you fetch the values from two columns using values from one column(get values from col.A if col.A is not null and get values from col.B if col.A is null)?

    Hi,
    Use NVL or COALESCE:
    NVL (col_a, col_b)
    Returns col_a if col_a is not NULL; otherwise, it returns col_b.
    Col_a and col_b must have similar (if not identical) datatypes; for example, if col_a is a DATE, then col_b can be another DATE or it can be a TIMESTAMP, but it can't be a VARCHAR2.
    For more about NVL and COALESCE, see the SQL Language manual: http://docs.oracle.com/cd/E11882_01/server.112/e26088/functions119.htm#sthref1310
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data.
    Explain, using specific examples, how you get those results from that data.
    Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
    See the forum FAQ: https://forums.oracle.com/message/9362002

  • Number of Days from a given Date

    How can one calculate the number of days in a month from a given date?
    Ex: If I pass 07/12/2008 it should return 31

    But your example doesn't meet the OP request. The OP wanted the number of days in a month where the month is determined by a specified date (paraprhased).
    DimaCit gave two credible solutions that met that requirement. Yours just counts the number of days between two apparently arbitrary dates.

  • I need to back up and sync multiple iPhones to a single iMac.  Each iPhone has a separate Apple ID and the data from each iPhone needs to be backed up separately from the others.  How can I do this without getting all of the contacts, etc. mixed? Tnx

    I need to back up and sync multiple iPhones to a single iMac.  Each iPhone has a separate Apple ID and the data from each iPhone needs to be backed up separately from the others.  How can I do this without getting all of the contacts, etc. mixed? Tnx

    This might help: http://support.apple.com/kb/HT1495.

  • TS2972 when i ask for Authorizeed computer i got the message " make sure your computer' date is set correctly and that it accepts cookies from the itunes stores " how can i solve this problem please .

    when i ask for Authorizeed computer i got the message " make sure your computer' date is set correctly and that it accepts cookies from the itunes stores " how can i solve this problem please .

    Ok, so I just worked out that itunes communicates through your browser so it's a cookie in the browser not PC direct that fixes this.  Bit of a convoluted route but for me it was IE>Internet setting>privacy>sites, then allow all activity from apple.com/itunes.

  • I want to remove all of my photos out of iPhoto there are approximately 35000 some imported from an old hard drive and a SD Card from my Nikon D500 how do I do this

    I want to remove all of my photos out of iPhoto there are approximately 35000 some imported from an old hard drive and a SD Card from my Nikon D500 how do I do this?
    I have iPhoto version 9.1.5 (615)
    Mac OS X version 10.6.8
    I want to do this because when I imported from my old hard drive there was an error message stating that 12 photos were not imported as the programm did not recognise the format even though they were jpegs like the other photos in that particular album. The dates of the photo folders are wrong I have multiple copies of photos and every time I start iPhoto I get the following message 12 photos have been found in the iPhoto library that were not imported would you like to import them No or Yes
    if you press Yes the same message comes back again and if you press Yes again the program flicks to last import for 2 seconds and then opens events.
    if you press No the message The photos have been placed in the folder/user/judith/pictures/iphoto Library recovered photos then if you press OK the original message 12 photos have been found.............
    if you press No at this point the message The photos have been placed in the folder/user /judith/pictures/iphoto Library recovered photos_11 the end number goes up by 1 every time you go through this process
    Any help would be greatly appreciated

    Did you import an iPhoto Library from the old Hard Drive? Do you still have that old Library?
    The way to clear out a Library is to Export the photos - Apps like iPhoto2Disk or PhotoShare will help you export to a Folder tree matching your Events.
    For the annoying start-up message:
    Go to your Pictures Folder and find the iPhoto Library there. Right (or Control-) Click on the icon and select 'Show Package Contents'. A finder window will open with the Library exposed.
    Look there for a Folder called 'Import' or 'Importing'.
    Drag it to the Desktop. *Make no other changes*.
    Start iPhoto. Does that help?
    If it does then look inside that folder on your desktop. Does it contain anything you want? If not you can trash the folder.

  • HT204053 How can I delete my iCloud account which I do not remember anything about the information that I entered about 4 years ago. It always asks my birth date but it seems I did not enter my correct date how can I bypass this question???

    How can I delete my iCloud account which I do not remember anything about the information that I entered about 4 years ago. It always asks my birth date but it seems I did not enter my correct date how can I bypass this question???

    You cannot delete the account from the server (partly to prevent the username from becoming available again and some-one else using it to pretend to be you).. Having disengaged your devices from it, go to http://icloud.com and delete any data in there such as contacts and calendars. Then just ignore it.

  • HT4259 KB article is out of date--how do you "allow this network to be extended" on AirPort Utility 6.x?

    The current KB article about extending wireless networks is out of date--how do you "allow this network to be extended" on AirPort Utility 6.x? These instructions describe v. 5.x.

    In my case, the option was required, so the problem was that it wasn't available. When I used v6.2 to extend the network on the secondary AP Express, it gave an error saying the network couldn't be extended.
    Once I booted Snow Leopard from an external drive, I was able to follow the instructions in HT4259 with v5. Once I checked the "allow this network to be extended" on the primary AP Express, the secondary AP Express started extending the network as it should.
    While v5 of the AirPort Utility is available for download, it won't work on Mountain Lion, so this solution wouldn't work for most people, who don't keep old operating systems lying around.

  • The circuit of my macbook is dead yet the hard drive is fine.  I need to access a file from the hard drive, how can i do this? is there a cable i can connect to another mac that will let me transfer the file?

    The circuit of my macbook is dead yet the hard drive is fine.  I need to access a file from the hard drive, how can i do this? The mac turns on the screen freezes as bright blue.  Is there a cable i can connect to another mac that will let me transfer the file?

    There is another option if the Macbook will start up in Target Disk Mode.
    Restart the computer while holding down the T key. If you see the firewire symbol moving around on the screen you can connect this one to another one in TDM. You will need a suitable cable to connect the two Macs.
    http://support.apple.com/kb/ht1661
    Firewire symbol:

  • Unable to delete email from trash bin.  How do I do this?  If I select and chose delete, it doesn't.  What am I doing wrong?  My grand daughte is using my iPad and I don't want her to see some of the mail there.

    Unable to delete email from trash bin.  How do I do this?  If I select and chose delete, it doesn't.  What am I doing wrong?  My grand daughte is using my iPad and I don't want her to see some of the mail there.

    There are two ways that should work. When you are in the trash folder, you can swipe on the email in the list - left to right - and a red Delete button should pop up. Or you can select - Edit - at the top of the list of messages and then select the message and tap delete.
    Not sure exactly how this works - but if you have restrictions enabled - especially since you let your grandchild use the device - that may be restricting what you can do in the mail app. Go to Settings>General>Restrictions. If you have it set to on - turn it off or see if you have mail restricted.

  • My 3rd iphone. 3GS I did not buy from an apple store, how do I register this serial number with my apple account? it is already sync to it and will preform every function except email to my home computer. It says apple ID disabled

    My 3rd iphone is a 3GS. I did not buy this one from the apple store, how do I register this serial number with my apple account? it is already sync'd and it and will preform every function except email to my home computer. It says apple ID disabled, also will not update my apps, same promt apple id disabled.
    anyone know where I can go to register this phone? Thanks

    https://register.apple.com

  • When I send a text from my iPad, it shows that it comes from my email address.  If I then text that same someone from my iPhone it still shows as if its coming from my iPad.  How do I stop this?

    When I send a text from my iPad, it shows that it comes from my email address.  If I then text that same someone from my iPhone it still shows as if its coming from my iPad.  How do I stop this?

    On your iPhone, go to Settings -> Messages -> Receive At -> Caller ID and make sure the phone number is selected - this will cause new messages sent from your iPhone to appear to come from your iPhone phone number.
    (I actually prefer to have my email selected, so that when I message someone from my iPhone and they reply, it goes to both my iPhone and iPad)
    Also, when you send a message from your iPhone, make sure you're not replying within an existing conversation (that was created on your iPad and linked to your email). Just start a new conversation (even if it's to the same person) by going to the Messages app, going back to "Messages" (top left corner) if you're already looking at a conversation, and then clicking the Compose icon in the top right.

  • I transferred my 3GS photos onto my enw iphone 5 ust to look at them. Now I am running out of storage. I need to save them to a computer so I can delte them from my phone. How can I do this?

    I transferred my 3GS photos onto my new iphone 5 ust to look at them. Now I am running out of storage. I need to save them to a computer so I can delete them from my phone. How can I do this?

    Hey bizteacher,
    Thanks for the question. Do you still have access to the iPhone 3GS? If so, follow these steps:
    iOS: Import personal photos and videos from iOS devices to your computer
    http://support.apple.com/kb/ht4083
    You could also follow these steps on your new iPhone 5, so long as the pictures are stored in your Camera Roll (as opposed to being synced to your phone).
    Thanks,
    Matt M.

  • Imessage doesn't work when i connect to my wifi only works on mobile date how do i fix this?

    Imessage doesn't work when i connect to my wifi only works on mobile date how do i fix this?

    1. Did you use Bootcamp Assistant?
    2. Did you build a USB with Windows 7 ISO and Bootcamp drivers?
    3. You should use a USB2.0 disk, not a USB3.0 disk (flash drive).
    4. What year is the Retina MBP?

Maybe you are looking for

  • Backup problem message: "no information about the ...

    Hi my problem is I want to backup my phone, which I've never done in the past so the first time I try it comes up with the message "no information about the latest backup available..." and it says something about try restoring already made backups if

  • Date/time does not update

    I am having the same problem with my iMac and new MacBookPro 13" with retina.   If I leave the computer on overnight (it goes to sleep and I wake it up in the morning), if I use the automatic feature in Word, QuickBooks, Quicken to insert today's dat

  • Just downloaded latest version--keeps trying to load last session-start new session does not work. Help?

    Here is the problem details. Am I going to have to uninstall? Problem Event Name: APPCRASH Application Name: firefox.exe Application Version: 1.9.2.4095 Application Timestamp: 4d852c95 Fault Module Name: ntdll.dll Fault Module Version: 6.0.6002.18327

  • Does Netflix on Apple TV work on Latam?

    Hi there I was almost to buy a Roku 3 for streaming but someone told that netflix on Roku doesnt work for Latam, so i was wondering if that same thing happens with the Apple TV. Please Help... Greetings EGP

  • 0x8004005 / Error: Configuration file is not well-formed XML

    Hello, I am getting a complete headache from this! I uninstalled Visual Studio 2013 Ultimate and installed in on another hard drive. Since then nothing works! It seems to be an error with IIS... The following happens: When I want to create ASP.NET Em