Get the half of the year (like quarter)

Hi guys,
I need to get the "half" of the year.
I am using the following...
Case
When CAST(DATEPART(quarter, Stock.VALUEDATE) as int)= 1 then '1'
When CAST(DATEPART(quarter, Stock.VALUEDATE) as int)= 2 then '1'
When CAST(DATEPART(quarter, Stock.VALUEDATE) as int)= 3 then '2'
When CAST(DATEPART(quarter, Stock.VALUEDATE) as int)= 4 then '2'
Else 'UnKnown'
End AS 'Half',
Is there any more elegant solution?  something like
DATEPART(half,Stock.ValueDate) AS 'Month'
Thanks.

this is the same as your logic, but using month... and in one line:
datepart(month,stock.[VALUEDATE])<=(6) then '1' else '2' end)
Or you can use Quarter:
datepart(quarter,stock.[VALUEDATE])<=(2) then '1' else '2' end)
Also, you may want to use 'Semester' rather than 'Half'.  The term 'Semester' suggests a date range, while 'Half' does not.... ALSO, in another field, you may want to concatenate the year to get a string result like '2013S1'.  Having the year with
the semester, quarter, or month, will help with grouping and other date based calculations.
here is the datepart function
http://msdn.microsoft.com/en-us/library/ms174420.aspx

Similar Messages

  • How to get the information like IP address,Host name of connected clients v

    Hi Every one,
    I want to get the information like (IP Address,Hostname,Active sessions , Database Server….etc) of the connected clients
    via V$Views(ORACLE).
    And then I like to load these infromation into a table “Client_Table”.
    Could some one give me suggestion that which V$ views/method I use in order to get the above information and then
    how to load these information into a table “Client_table”?
    Your suggestions will be highly appreciated.
    With Regards
    BILAL

    You could use a LOGON TRIGGER so every session insert its own environment into your client_info table.
    You could use the following view and choose whatever attribute you need:
    create or replace view my_userenv (
    AUDITED_CURSORID ,
    AUTHENTICATION_DATA ,
    AUTHENTICATION_TYPE ,
    BG_JOB_ID ,
    CLIENT_IDENTIFIER ,
    CLIENT_INFO ,
    CURRENT_SCHEMA ,
    CURRENT_SCHEMAID ,
    CURRENT_SQL ,
    CURRENT_USER ,
    CURRENT_USERID ,
    DB_DOMAIN ,
    DB_NAME ,
    ENTRYID ,
    EXTERNAL_NAME ,
    FG_JOB_ID ,
    GLOBAL_CONTEXT_MEMORY ,
    HOST ,
    INSTANCE ,
    IP_ADDRESS ,
    ISDBA ,
    LANG ,
    LANGUAGE ,
    NETWORK_PROTOCOL ,
    NLS_CALENDAR ,
    NLS_CURRENCY ,
    NLS_DATE_FORMAT ,
    NLS_DATE_LANGUAGE ,
    NLS_SORT ,
    NLS_TERRITORY ,
    OS_USER ,
    PROXY_USER ,
    PROXY_USERID ,
    SESSION_USER ,
    SESSION_USERID ,
    SESSIONID ,
    TERMINAL
    ) AS SELECT
    SYS_CONTEXT ('USERENV', 'AUDITED_CURSORID') ,
    SYS_CONTEXT ('USERENV', 'AUTHENTICATION_DATA') ,
    SYS_CONTEXT ('USERENV', 'AUTHENTICATION_TYPE') ,
    SYS_CONTEXT ('USERENV', 'BG_JOB_ID') ,
    SYS_CONTEXT ('USERENV', 'CLIENT_IDENTIFIER') ,
    SYS_CONTEXT ('USERENV', 'CLIENT_INFO') ,
    SYS_CONTEXT ('USERENV', 'CURRENT_SCHEMA') ,
    SYS_CONTEXT ('USERENV', 'CURRENT_SCHEMAID') ,
    SYS_CONTEXT ('USERENV', 'CURRENT_SQL') ,
    SYS_CONTEXT ('USERENV', 'CURRENT_USER') ,
    SYS_CONTEXT ('USERENV', 'CURRENT_USERID') ,
    SYS_CONTEXT ('USERENV', 'DB_DOMAIN') ,
    SYS_CONTEXT ('USERENV', 'DB_NAME') ,
    SYS_CONTEXT ('USERENV', 'ENTRYID') ,
    SYS_CONTEXT ('USERENV', 'EXTERNAL_NAME') ,
    SYS_CONTEXT ('USERENV', 'FG_JOB_ID') ,
    SYS_CONTEXT ('USERENV', 'GLOBAL_CONTEXT_MEMORY') ,
    SYS_CONTEXT ('USERENV', 'HOST') ,
    SYS_CONTEXT ('USERENV', 'INSTANCE') ,
    SYS_CONTEXT ('USERENV', 'IP_ADDRESS') ,
    SYS_CONTEXT ('USERENV', 'ISDBA') ,
    SYS_CONTEXT ('USERENV', 'LANG') ,
    SYS_CONTEXT ('USERENV', 'LANGUAGE') ,
    SYS_CONTEXT ('USERENV', 'NETWORK_PROTOCOL') ,
    SYS_CONTEXT ('USERENV', 'NLS_CALENDAR') ,
    SYS_CONTEXT ('USERENV', 'NLS_CURRENCY') ,
    SYS_CONTEXT ('USERENV', 'NLS_DATE_FORMAT') ,
    SYS_CONTEXT ('USERENV', 'NLS_DATE_LANGUAGE') ,
    SYS_CONTEXT ('USERENV', 'NLS_SORT') ,
    SYS_CONTEXT ('USERENV', 'NLS_TERRITORY') ,
    SYS_CONTEXT ('USERENV', 'OS_USER') ,
    SYS_CONTEXT ('USERENV', 'PROXY_USER') ,
    SYS_CONTEXT ('USERENV', 'PROXY_USERID') ,
    SYS_CONTEXT ('USERENV', 'SESSION_USER') ,
    SYS_CONTEXT ('USERENV', 'SESSION_USERID') ,
    SYS_CONTEXT ('USERENV', 'SESSIONID') ,
    SYS_CONTEXT ('USERENV', 'TERMINAL')
    from dual;

  • PowerShell Script to get the details Like Scope,Last Deployed date and Name for a Solution Deployed in the Farm.

    Hi Experts,
    I am trying to  build a PowerShell Script to get the details Like Scope,Last Deployed date and Name for a Solution Deployed in the Farm.
    Can anyone advise on this please.
    Regards

    Get-SPSolution|Select Name,Scope,LastOperationResult,LastOperationEndTime|Export-CSV "SPInstalledSolutions.csv" -NoTypeInformation
    SPSolution properties
    Get-SPSolution
    This post is my own opinion and does not necessarily reflect the opinion or view of Slalom.

  • Hi why do i getting the message like "Your payment method was declined"

    hi why do i get the message like "Your payment method was declined"

    What are you trying to use as your payment method, credit card, debit card ... ? If it's a debit card then I don't think that they are still accepted as a valid payment method in all countries - from this page :
    You may be able to use other payment types in your country, like debit and Maestro cards.
    which implies that they are not accepted in all countries, and there have been a number of posts about them being declined.
    For a card to have a chance of being accepted it needs to be registered to exactly the same name and address (including format and spacing etc) that you have on your iTunes account, and have been issued by a bank in the country where you and your iTunes account are. If it is then you could check with the card issuer to see if it's them that are declining it, and if not then try contacting iTunes Support (these are user-to-user forums) and see if they know why it's being declined (but you might not be able to use a debit card) : http://www.apple.com/support/itunes/contact/ - click on Contact iTunes Store Support on the right-hand side of the page, then Account Management

  • Get the year out of a date

    I have a date '12/02/1989'. how do i get the year out of this date.
    or take a sysdate and get the year out of it.
    Thanks

    this?
    SQL> ed
    Wrote file afiedt.buf
      1  SELECT EXTRACT (YEAR FROM TO_DATE('12/02/1989','mm/dd/yyyy')) year
      2* FROM dual
      3  /
          YEAR
          1989
    or this/
    SQL> ed
    Wrote file afiedt.buf
      1  SELECT to_char( TO_DATE('12/02/1989','mm/dd/yyyy'),'YYYY') year
      2* FROM dual
    SQL> /
    YEAR
    1989too late
    Message was edited by:
    devmiral

  • Why is it that whenever someone text me i only get the message like 15 minutes later

    i text somone and they reply right away but i dont get the message like 15 mins later 
    ipod touch 4 8gb

    It is just server delay. Nothing you can do about it.

  • Howto to get the year timestamp in syslog and logadm files

    5.10 Generic_141414-10 sun4u sparc
    Howto to get the year timestamp in syslog and logadm
    We have to keep logs files for a long time, I was exploring logs in /var/adm/secure and noticed that log files over a year old did not have a year time stamp, they are in this format:
    Nov 12 09:09:16
    And on the face of it. /varlog/syslog is the same, I thought no problem, there will be something in syslog.conf or logadm.conf I change and it will be fixed, but I cannot find any options to change this, how do I get the year in my log files?
    The "date" command does output the year:
    Friday, September 14, 2012  7:57:36 AM

    My guess is that the fields in a message logged by syslog are fixed, so you can't add a field to it.
    The reason for this is simply that there might be other applications parsing your syslog messages, or there might be other systems syslogging to your system, and that would break if you would add fields.
    The easiest workaround is probably to keep better track of your logs by either implementing an annual rotation of them from crontab, or log the date using the "logger" command on a regular basis.
    A third option would be to look at syslog-ng or rsyslog, which is more flexible when it comes to storing logs, and among other things can store them into a SQL db..
    .7/M.

  • Hi. I want to make a perpetual (Birthdays) calendar so don't want it to have a year printed on it. CAn't seem to get the year removed. anyone else tried this? Succeeded????

    Using iPhoto Version 9.5.1
    I want to make a calendar that has no year printed on it - so it is a perpetual calendar, for birthdays.
    I can't remove the year from the options.  If I remove the date I get 0001 no matter what.

    Please quote the exact error message, word-for-word, verbatim.
    What is your operating system?
    What version of Lightroom?

  • Updated to Mavericks and I get the upper left quarter of the screen blacked out on Time Machine. This means that I can't see the files. Any suggestions for getting rid of the black square?

    Ive tried disconnecting and reconnecting the Time Machine. And I've tried rebooting the iMac, but I still get the top left hand quarted of the screeen blacked out. I can scroll back through the back-ups but the back square means that I can't see the details of any file.

    Please read this whole message before doing anything.
    This procedure is a diagnostic test. It’s unlikely to solve your problem. Don’t be disappointed when you find that nothing has changed after you complete it.
    The purpose of the test is to determine whether the problem is caused by third-party software that loads automatically at startup or login, by a peripheral device, or by corruption of certain system caches. 
    Disconnect all wired peripherals except those needed for the test, and remove all aftermarket expansion cards. Boot in safe mode and log in to the account with the problem. Note: If FileVault is enabled on some models, or if a firmware password is set, or if the boot volume is a software RAID, you can’t do this. Ask for further instructions.
    Safe mode is much slower to boot and run than normal, and some things won’t work at all, including sound output and  Wi-Fi on certain models. The next normal boot may also be somewhat slow.
    The login screen appears even if you usually log in automatically. You must know your login password in order to log in. If you’ve forgotten the password, you will need to reset it before you begin. Test while in safe mode. Same problem? After testing, reboot as usual (i.e., not in safe mode) and verify that you still have the problem. Post the results of the test.

  • How can I get the sounds , like clicking,etc to work on iPad 2 with IOS 5. In the settings all sounds are on and the volume is high but I don't get a sound.

    After downloading IOS 5, I no longer get the sounds on my IPAD 2 to work. They are on in settings and the volume is at maximum, but the sounds such as keyboard click, email sent etc, donor work.
    Any suggestions.
    Regards

    Have you got notifications muted ? Only notifications (including games) get muted, so the iPod and Videos apps, and headphones, still get sound.
    Depending on what you've got Settings > General > Use Side Switch To set to (mute or rotation lock), then you can mute notifications by the switch on the right hand side of the iPad, or via the taskbar : double-click the home button; slide from the left; and it's the icon far left; press home again to exit the taskbar. The function that isn't on the side switch is set via the taskbar instead : http://support.apple.com/kb/HT4085

  • Function Module to get the data like in LS26

    Hi Gurus,
    We are designing a new program and we need to get information about the "available stock", "putaway stock" and "pick quantity" for some storage types. So this is exactly what the LS26 shows.
    Do you know any Function Module that can extract or calculate this information?
    I would really appreciate any suggestion.
    Thank you in advance
    Edited by: Abel Raya on Jul 4, 2011 11:39 AM

    I don't think there is a function module exists. But you can get the details from table LQUA for item details and LEIN for header records.

  • Getting the year from the date field

    Hi,
    Please  ltet me know how to  get only YEAR form the DATE field
    Thanks in advance
    Ajay

    data:
    date like sy-datum,
    year(4) type c,
    month(2) type c,
    day(2) type c.
    year = date(4).
    month = date+4(2).
    day = date+6(2).
    Regards,
    Michael
    Please mark question as anwered if so....

  • I can't get the websites like youtube, facebook, etc to load. everything comes up as just text/words. i've downloaded adobe flash and real player on windows xp.

    i have windows xp. i just got the computer and internet on it. i downloaded adobe flash and real player. but i still can't get sites like facebook and youtube to work. i always get popups that ask if its a trusted site and to add the exception, which i do. yahoo and msn work, i can see photos and pictures and images just fine, but facebook and youtube are still all just words and error messages. any suggestions besides what i've already tried? i'm not tech savvy so step by step is how i learn best!

    Check the date and time and time zone in the clock on your computer: (double) click the clock icon on the Windows Taskbar.
    Check out why the site is untrusted and click "Technical Details" to expand this section.
    If the certificate is not trusted because no issuer chain was provided (sec_error_unknown_issuer) then see if you can install this intermediate certificate from another source.
    You can retrieve the certificate and check details like who issued certificates and expiration dates of certificates.
    *Click the link at the bottom of the error page: "I Understand the Risks"
    Let Firefox retrieve the certificate: "Add Exception" -> "Get Certificate".
    *Click the "View..." button and inspect the certificate and check who is the <b>issuer of the certificate</b>.
    You can see more Details like intermediate certificates that are used in the Details pane.
    If <b>"I Understand the Risks"</b> is missing then this page may be opened in an (i)frame and in that case try the right-click context menu and use "This Frame: Open Frame in New Tab".
    *Note that some firewalls monitor (secure) connections and that programs like Sendori or FiddlerRoot can intercept connections and send their own certificate instead of the website's certificate.
    *Note that it is not recommended to add a permanent exception in cases like this, so only use it to inspect the certificate.

  • Can't Get the Facebook Like Button To Work

    So I've put a like button on my website, and I can't seem to get it to work. I put my company's facebook URL as the target URL. Then I publish, click "like", and nothing happens. Will they not work while it's being hosted on BC? Do I have to upload to an FTP host before the widget will function properly?

    Hello,
    In the widgets Option you have inserted page URL as "http://https/www.facebook.com/pages/Mother-Ducts-Environmental-LLC/239947229505852?ref=br_ tf"
    Please enter only "www.facebook.com/pages/Mother-Ducts-Environmental-LLC/239947229505852?ref=br_tf"   (Without HTTP)
    Reupload the site and then try.
    Regards
    Vivek

  • I am facing an issue to get the data like JE_SOURCE='Purchasing' and je_category='Accruals' .

    Columns in my report like
    accounted_dr
    ,accounted_cr
    ,PO#
    ,VENDOR NAME
    Suggest me how to implement the query with above details.

    Hi,
    Please post the detailed error message, it’s more helpful for further troubleshooting.
    Since the add-in is related to Outlook client, I recommend contact Outlook for Developers Team so that you can get more professional suggestion.
    For your convenience:
    https://social.msdn.microsoft.com/Forums/en-US/home?forum=outlookdev&filter=alltypes&brandIgnore=True&sort=relevancedesc&filter=alltypes&searchTerm=
    Thanks
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact [email protected]
    Allen Wang
    TechNet Community Support

Maybe you are looking for

  • All webmail folders do not appear in my new imac mail

    how can i configure my mac mail so that all my web based email folders will be displayed there?

  • Recovery of lost file is it possible

    I like to recover chat messages from Nov 6, 2012 to Decemeber 2012, can some help please

  • Cant Update other Country mobile

    i bought lumia 900 from US. i have downloaded the Bluetooth Share from Market Place. while opening that its showing the ERROR message to update higher version.now i m in INDIA i contact Nokia care and customer care thay telling if we update the S / W

  • Making call from Calendar

    I just switched from a Blackberry where I was very able to make calls from my address book. Each day I would move "to do" items to the next day's calendar and call from the calendar when driving or off site. Is there a way I can do this in my I phone

  • Entry missing from calendar

    I am trying to add an entry to my calendar and my phone shows 6 calendars, two yahoo accounts, then iCloud calendar, work, home all marked/checked. I create my entry it appears on my calendar list for a minute then disappears! It has removed all my p