CAST,CONVERT and SUBSTRING

Hi,
I have a coumn called Date
DAte: 2014-05-12 00:00:00.000 (yyyy-mm-dd time)
Now i need to change this to two Column called Season and DateMM
where 
DateMM: 201405 (yyyymm) and 
season : FA14  ( since its a fifth month I want to call it as FA  and the 14 is from 2014).
Anyone who can help?
SPPandey

Are the seasons defined
considering northern or southern hemisphere?
The
beginning and
end of each season
varies
according to the hemisphere
and even
country.Vide
equinox and
solstice.
Try
-- code #1
;with
Frank as (
SELECT [Date], AAAAMM= Convert(char(6), [Date], 112),
MMDD= Right( Convert(char(8), [Date], 112), 4)
from ...
SELECT [Date],
DateYM= AAAAMM,
Season= case when MMDD >= '0320' and MMDD < '0620' then 'AU'
when MMDD >= '0621' and MMDD < '0922' then 'WI'
when MMDD >= '0923' and MMDD < '1221' then 'SP'
else 'SU' end +
Right('00' + Cast((Year([Date]) % 100) as varchar), 2)
from Frank;
  or
-- code #2
CREATE FUNCTION SeasonYear (@Date date)
returns char(2) as
begin
declare @MMDD char(4), @S char(2);
set @MMDD= Right( Convert(char(8), @Date, 112), 4);
set @S= case when @MMDD >= '0320' and @MMDD < '0620' then 'AU'
when @MMDD >= '0621' and @MMDD < '0922' then 'WI'
when @MMDD >= '0923' and @MMDD < '1221' then 'SP'
else 'SU' end;
return @S;
end;
go
SELECT [Date],
DateYM= Convert(char(6), [Date], 112),
Season= dbo.SeasonYear([Date]) +
Right(Convert(char(4), [Date], 112), 2)
from ...;
José Diz     Belo Horizonte, MG - Brasil

Similar Messages

  • IF and SUBSTR in XML Publisher

    Hi
    I am developing a XML RTF template for a report.
    All I am trying to do is, if first 4 letters of the data of xml tag ITEM = 'Summ'
    then print a constant word 'Notes'
    <?if: xdofx:substr(ITEM,1,4)=’Summ’?> Notes<?end if?>
    I have been trying hard. IF and SUBSTR is not at all going along. Always throwing some error. Can some one please help me to resolve this issue
    Thanks

    Hi,
    I have a similar requirement, however instead of static text in the example i.e ITEM I am trying to get a substring from a tag value directly. Ex - Tag Value <eod>23-10-2009<eod>. I am trying to pick up the value 10 in the particular example and trying to compare with 1, which would be false and hence I need to print as false. I cannot use a hardcoded value since the value between the tags <eod> is dynamic and I need to use that itself.
    Can you please provide me with the sytax which can achieve this?
    Regards,
    Praseed

  • Video Format Total Solution: How to Convert and Edit Video on Windows/Mac

    More and More video formats are coming out with different video encoders and it makes our spare time more and more colorful. However, it is not to say that there is no problems. Actually, different video formats make it difficult to share video with others, even your own camcorder and iPod. Is there an easy way to convert videos effectively. Yes, there is.
    In this article, I will show you guys how to convert videos on windows and mac.
    Part 1. How to Convert and Edit Videos on Windows
    For Windows users, you need a Video Converter(http://www.aiseesoft.com/total-video-converter.html) to do that for you.
    Here I use Aiseesoft Total Video Converter(http://www.aiseesoft.com/total-video-converter.html)
    Step 1: Download and install Aiseesoft Total Video Converter
    After you download it to your computer, double click it and it is really easy to install.
    You just need to click “next” and it will complete it in seconds. It will automatically run after installation.
    http://www.aiseesoft.com/images/guide/total-video-converter/screen.jpg
    Step 2: Load Video
    Click “Add File” to find the video that you want to convert and click “open”. It will be loaded automatically.
    Step 3: Select the target to decode
    In the “Profile” drop download list you can find your target according the usage of your output video, such as if you want to put the video on your iPod touch, you can select the “iPod” in the first list and “iPod touch 2 MPEG-4 640*480(*.mp4)” in the second list.
    Step 4: Set Advanced Parameters
    After you select the right output profile, you can click “setting” button to set your advanced parameters. You can adjust video and audio settings separately. In video section, you can change “video encoder”, “resolution”, “frame rate”, “video bitrate”In audio section, you can change “audio encoder”, “sample rate”, “channel”, “audio bitrate”If you want to save this profile and settings and use it next time you can click “save as” button to give a name to it. And the next time you want to use it you can find it in the profile list named “user defined”.
    Step 5: Choose a Destination
    To browse and find a output folder for your output files or just the default one.
    Finally, Click “Convert” button to begin your conversion, here in the converting
    interface you can choose “shut down the computer when conversion complete” or “open output folder when conversion complete” or you just do not choose neither one.
    Tips: How to Edit the Output Video
    This video converter is also a video editor, you can use it to edit your output video as follows:
    http://www.aiseesoft.com/images/guide/total-video-converter/effect.jpg
    1. Effect:
    You are allowed to adjust the “Brightness”, “Contrast”, “Saturation” and you can choose the “deinterlacing” to make the video more enjoyable.
    2. Trim:
    In “Trim” section you can pick up any part of the video to convert.
    There are two ways to select the part of the video you want. One is set the start and end time in the box. The other one is to drag the start and end button in the processing bar.
    3. Crop:
    This function allows you to choose a certain play area to convert. That means you can choose a part of the screen you like to convert. For example, you just like the tv in the middle of the screen, then you can drag the frame around the preview window to select the tv and the output preview will show you the output video.In this section you can also choose the “zoom mode”, such as “keep original”, “full screen”, “16:9”, “4:3”.
    4. Watermark
    In the section, you can add a watermark on the output video to show people something, such as your name, website, studio name or other things. The watermark could be words and picture. You can adjust the transparent of the watermark easily to make it more beautiful.
    Part 2. How to Convert Video on Mac
    This time you need a Video Converter for Mac(http://www.aiseesoft.com/video-converter-for-mac.html)
    Step 1: Add File
    Click “Add File” button to load the video you want to converter
    http://www.aiseesoft.com/images/guide/mac-video-converter/steps.jpg
    Step 2: Choose profile and adjust settings
    You can find your output video format from a drop-list called “Profile”You can also adjust the specific settings of the output video, such as “Resolution”, “Bitrate”, “Encoder” and so on.

    @ Tamwini
    Your only goal is to sell software.
    ‡Thank you for hitting the Blue/Green Star button‡
    N8-00 RM 596 V:111.030.0609; E71-1(05) RM 346 V: 500.21.009

  • What is a good way to convert and open a .cwk file?

    Trying to convert and open a .cwk file.  Pretty sure it's an old ClarisWorks file but I got it as an attachment in an email and my iPhone mail won't allow me to open it AT ALL...Please, Help...

    All AppleWorks (& ClarisWorks) files will have the .cwk extension. The iWork applications - Keynote, Pages & Numbers - can only open AppleWorks 6 presentation, word processing & spreadsheet documents, respectively. They will not open any other type of AppleWorks 6 files or any AppleWorks 5 or any version of ClarisWorks files.
    Since you're running Tiger you can run AppleWorks 5 or 6 as well as earlier versions of ClarisWorks in Classic. If you don't have AppleWorks, I recommend getting AppleWorks 6.2.4 which will open .cwk files & save the presentation, word processing & spreadsheet documents as something the iWork apps can open.

  • Embedding video in PDF, keeps says it cant convert and need Acrobat Pro Extended?

    I have Acrobat Pro 9 and with using the tool to embed video which seems to convert to a flash format, it keeps coming back saying its unable to convert and that I would need Acrobat Pro Extended.  I tried a handfull of different video types and every one that I chose gave me the same message.  All it will seem to do is somehow link to the video whcih will use the viewer installed on that persons computer to run.  It seems to give you the ability to convert video over but it doesnt let you for anything you choose, what am I doing wrong?
    I have Acrobat Pro 9 Extended at work which I tried the same thing with and of course, that worked.  Is the Extended part by any chance just a patch for Pro 9 or is it a totally different purchase?

    "Add multimedia to PDFs" at Acrobat Pro's LiveDocs may help to clarify.
    http://help.adobe.com/en_US/Acrobat/9.0/Professional/WS65B80E79-F165-44f0-BBCA-0F142A75869 6.html
    Looks like the following general observations apply.
    If the multmedia file(s) meet the identified requirements for Professional it is "in".
    If the multimedia file(s) do not, then conversion is required - but conversion is only available in Pro Extended.
    That you get a "need conversion" message, from Pro that would be indicative of an input that does not meet the specified requirements for direct use in Pro.
    An alternative might be to try "Create Legacy ..."
    Legacy multimedia will rely on the end-user having the appropriate player application installed.
    fwiw - having an interest in multimedia & PDF you might find this helpful
    Video and Audio file formats supported in Acrobat 9 and Adobe Reader 9
    http://kb2.adobe.com/cps/405/kb405848.html
    Be well...

  • I bought a canon EOS Rebel T5i. It came with photoshop elements 11.  PS won't open my C2 raw files and says my camera isn't supported by the software I have downloaded 7.4 dng converter and I still can't open the files.  What do I need to do?

    I bought a canon EOS Rebel T5i. It came with photoshop elements 11.  PS won't open my C2 raw files and says my camera isn't supported by the software I have downloaded 7.4 dng converter and I still can't open the files.  What do I need to do?

    You need camera raw 8.4 for your camera, if it’s Digital Rebel T5 EOS 1200D EOS Kiss X70. It is not compatible with PSE11; so it’s a bit odd if that software was bundled with the camera except that it will work with jpegs. I suggest you download and install the free Adobe DNG converter to convert your CR2 files to the Adobe universal Raw format and the DNG files will editable in PSE11(keep your originals as backups and for use in the camera manufactures software)
    Mac download (.dmg file) click here DNG Converter 8.4
    You can convert a whole folder of raw images in one click. See this quick video tutorial:
    You Tube click here for DNG Converter tutorial

  • CS4 will not open NEF files. I installed DNG converter and it did not help.

    CS4 will not open NEF files. I installed DNG converter and it did not help. Also, I tried to just "update" photoshop and it did not work. It is a new camera (Nikon 1).

    Yes, you need CS6. DNG Converter is just a standalone tool to convert RAW to DNG files which then may be possible to open in older versions of Adobe tools.
    Mylenium

  • I just downloaded the free trial of Adobe PDF to Word converter and was not able to convert a PDF file to word. Could anyone please help? Thx

    I just downloaded the free trial of Adobe PDF to Word converter and was not able to convert a PDF file to word. Could anyone please help? Thx

    Part of the problem in helping is likely that there is no program Adobe -- that is the company name. You are in the Acrobat forum, but it sounds like you have subscribed to Export PDF or such, a different program. The subscription to Acrobat is currently $19.99 per month.

  • Acrobat 9 - Convert and Combine

    I have a folder structure (thousands of folders) with multiple layers of subfolders.  I am trying to convert and combine all TIFF files in each subfolder to one PDF file.  I want that PDF file to be located in the original file structure.  In other words, each subfolder should have one PDF that is the combination of all TIFF files in that folder.
    I know I can convert all TIFF files by using the batch processing feature.  That feature will locate the new PDF files in the original file location, which is what I want.  Is Acrobat able to perform the second part of my need, to then combine those PDFs by subfolder?  The "Combine supported files in Acrobat" feature doesn't seem to help since it would have to be run on each folder separately.
    Any help would be greatly appreciated!

    Instead of hiring an expensive programmer, just download some non-adobe PDF program like image2pdf and use a Windows batch file:
    FOR /F "tokens=*" %%G IN ('DIR /B /AD /S *.*') DO image2pdf -i "%%G\*.TIF" -o "%%G\output.pdf" "%%G"
    pause
    Place the batch file in a directory as high up as you want to go. So say you have:
    -top level
    --scans L1
    ---scans L2
    ----your files here
    --scans L1
    ---scans L2
    ----your files here
    --scans L1
    ---scans L2
    ----your files here
    Place that batch file in the top level folder and it will go through and create PDF files for you. My method isn't perfect - it's difficult to dynamically name every PDF file and you're going to get an output.pdf file in every folder, regardless of whether or not there are files in it...but at the most basic raw level, it works and can save tons of time.

  • I need easy audio and video converting and editing software?

    I need easy audio and video converting and editing software that wont cost $400.

    I highly recommend you try Video Monkey. It's free, though donations are certainly accepted, and does an excellent job of converting .mov to .wmv. Choose Best (2 Pass) for Encoding Speed and depending upon the size of your original file, uncheck 320 pixels wide to create a larger converted image. I set Quality to "Go Nuts".
    Another good commercial program is Video Converter Ultimate for Mac. It works as video converter and editor. The version for 2 Pass conversion is approximately $69. , which is considerably less than the $400+ that Adobe Premiere is asking for its editor. I'd still prefer a freebie though, but there's little choice...

  • Materialized Views and Substr ?

    Hi,
    I'm currently trying to create a materialized view that can be fast refreshed, but it complains each time. I think it's because I'm using a constraint substr(x,1,10) so complete refreshes are all that can be done?
    My steps are :
    create materialized view log on a_table with rowid;
    create materialized view log on b_table with rowid;
    create materialized view log on c_table with rowid;
    create materialized view log on d_table with rowid;
    and the materialized view is
    create materialized view MY_VIEW
    build immediate
    enable query rewrite
    REFRESH FAST
    as
    SELECT bt.mid AS mid, ct.imid AS imid, bt.iid AS iid, vendor_name AS make, at.dname AS dname, bt.timestamp AS timestamp
              FROM b_table bt, c_table ct, d_table dt, a_table at
                   WHERE bt.mid=ct.mid
                        AND substr(bt.iid,1,5)=dt.val1
                        AND at.profile_id=dt.profile_id
              order by bt.timestamp desc;
    ORA-12052: cannot fast refresh materialized view MY_VIEW
    I'm at a loss, I can make it without the fast refresh, but the table view is huge and updating it completely each time isn't going to work :(
    Any help or suggestions would be greatly appreciated,
    Regards,
    Brian

    Well, basically, you can relatively easily find it out yourself.
    First, there is a very useful script $ORACLE_HOME/rdbms/admin/utlxmv.sql
    You should execute under the same account as you create materialized views like this
    @?/rdbms/admin/utlxmvThen you are prepared to check, whether your mv is fast refresheable and if not - why.
    SQL> create table new_dept as select * from dept
      2  /
    Table created.
    SQL> -- Now create table emp with new join column of type varchar2
    SQL> create table new_emp as
      2  select e.*,d.dname
      3  from emp e,dept d
      4  where e.deptno=d.deptno
      5  /
    Table created.
    SQL> create materialized view log on new_emp with rowid
      2  /
    Materialized view log created.
    SQL> create materialized view log on new_dept with rowid
      2  /
    Materialized view log created.
    SQL> begin
      2          dbms_mview.explain_mview('select e.*,d.loc
      3                  from new_emp e,new_dept d
      4                  where substr(d.dname,1,10)=e.dname');
      5  end;
      6  /
    PL/SQL procedure successfully completed.
    SQL> select capability_name,possible,msgtxt
      2  from  mv_capabilities_table
      3  where capability_name like '%FAST%'
      4  /
    CAPABILITY_NAME                PO MSGTXT
    REFRESH_FAST                   N
    REFRESH_FAST_AFTER_INSERT      N  the SELECT list does not have the rowids
                                       of all the detail tables
    REFRESH_FAST_AFTER_ONETAB_DML  N  see the reason why REFRESH_FAST_AFTER_IN
                                      SERT is disabled
    REFRESH_FAST_AFTER_ANY_DML     N  see the reason why REFRESH_FAST_AFTER_ON
                                      ETAB_DML is disabled
    REFRESH_FAST_PCT               N  PCT is not possible on any of the detail
                                       tables in the materialized view
    SQL> rollback
      2  /
    Rollback complete.
    SQL> -- Now we know - for materialized view rowid of all involved in join tables
    SQL> -- should be in the select list to make possible fast refresh
    SQL> -- of course they should get proper aliases. Yet one attempt
    SQL> begin
      2    dbms_mview.explain_mview('select e.*,e.rowid erow_id,d.loc,d.rowid drow_id
      3      from new_emp e,new_dept d
      4      where substr(d.dname,1,10)=e.dname');
      5  end;
      6  /
    PL/SQL procedure successfully completed.
    SQL> select capability_name,possible,msgtxt
      2  from  mv_capabilities_table
      3  where capability_name like '%FAST%'
      4  /
    CAPABILITY_NAME                PO MSGTXT
    REFRESH_FAST                   Y
    REFRESH_FAST_AFTER_INSERT      Y
    REFRESH_FAST_AFTER_ONETAB_DML  Y
    REFRESH_FAST_AFTER_ANY_DML     Y
    REFRESH_FAST_PCT               N  PCT is not possible on any of the detail
                                       tables in the materialized view
    SQL> -- Mission successful - refresh_fast is possibleBest regards
    Maxim

  • PL-SQL Solve: Using INSTR and SUBSTR

    I am trying to work on this and cannot get a solution. Please help
    You have to use INSTR and SUBSTR to solve
    Question:
    You have the following acceptable value
    Numberic: 0-34
    80-100
    or Non Numberic X S U D- D D+
    Im have to use INSTR and SUBSTR functions to test that the value is a valid (as above) number before TO_NUMBER is called:
    SELECT TO_NUMBER('?? ') //HERE ?? and a space (for 100 etc) is for the values as above
    FROM DUAL
    WHERE ....INSTR(......)<=;
    (Hence if the number is true then number comes back or it says no rows)
    and also id non numberic it should also be tested.
    I am completely unsure about it but tried this
    SELECT TO_NUMBER('34 ')
    FROM DUAL
    WHERE INSTR('0123456789',1,1)<=9 (looking at first number ?)
    AND
    INSTR('0123456789',2,2)<=9
    AND
    INSTR('0123456789',3,3)=0;
    Please help

    We have the following value that we can use:
    Numeric: 0-34 and 80-100 only
    or Non Numberic X S U D- D D+
    Have to use INSTR and SUBSTR functions to test that the value is a valid
    (for now only trying to create a function which can later be put into a procedure.)
    SELECT TO_NUMBER('12 ') //e.g HERE 12 and a space for the values as above
    FROM DUAL
    the where clause looks at all three spaces to make sure values are correct (given number or non-numberic values only)
    (Hence if the number is true then number comes back (meaning true)
    or it says NO rows)
    If value is non numeric, test it to allow non numberic also.
    I am completely unsure about it but tried this
    SELECT TO_NUMBER('34 ')
    FROM DUAL
    WHERE INSTR('0123456789',1,1)<=9 (looking at first number ?)
    AND
    INSTR('0123456789',2,2)<=9
    AND
    INSTR('0123456789',3,3)=0;
    Something like this has to be done.....subst (instr, x,x,) i think mite help.

  • Using MacBook Pro to convert pdf to word doc...downloaded...converted, and what I got was illegible. What's the deal?

    Using MacBook Pro to convert pdf to word doc...downloaded...converted, and what I got was illegible. What's the deal? Did I miss a couple steps along the way?

    Hi Deborah,
    Please Elaborate your issue so that i can assist you better.
    Regards,
    Rahul

  • As of yesterday I cannot download pdf files. Instead I get a pop up box that says CONVERT and gives me dozens of programs. How do I just download without this box stopping me?

    i click on any pdf file and instead of it just downloading and opening automatically as it has always done - instead it shows the download box and then another pops up titled CONVERT and then gives me a million different options - word / excel / every version of every one! DOS. even if i pick one it comes up in computer language. As of 2 days ago it worked properly and in Safari or another program I can open the pdf. What's happening? HELP

    You can try "Reset Download Actions"
    * http://kb.mozillazine.org/File_types_and_download_actions

  • How to convert and edit HD video

    Because of the widely using of HD Camcorder, now it is really convenient to record family parties and other things you are interested in. Nowadays, people would like to share their things with the rest of the world through Internet, such as youtube.com and other video websites.
    This guide aims to show you how to convert and edit the video you recorded using your HD camcorder
    What you need is a powerful HD Converter.
    Step 1: Load Video
    Click “Add File” to load the video that you want to convert.
    Step 2: Choose Your Output Profile and Settings.
    From “Profile” drop-down list you can choose your output profile according to your need.
    You can also click “setteing”adjust the settings of your output video, such as “video/audio encoder”, “Video/audio Bitrate”, “Channels”, “Resolution” and so on..
    Step 3: Video Editing.
    This powerful MTS Converter allows you to do many video editings.
    1. Click "Effect". to make special effect for your movie.
    You can adjust the “Brightness”, “Contrast”, “Saturation” and also you can use “deinterlacing” to improve you output effect.
    2. Trim: .
    “Trim” function allows you to pick up any part of your video to convert. You can just convert a part of your video that you want.
    3: Crop: .
    Cut off the black edges of the original movie video and watch in full screen on your iPod using the "Crop" function.
    Step 4: Conversion.
    After you have done all the steps above you can click “Start” button to start your conversion.
    Here I also recommend you some High Definition video converter, MTS Converter, M2TS Converter.
    Hulu Downloader
    Total Video Converter
    Best DVD Ripper

    @ Tamwini
    Your only goal is to sell software.
    ‡Thank you for hitting the Blue/Green Star button‡
    N8-00 RM 596 V:111.030.0609; E71-1(05) RM 346 V: 500.21.009

Maybe you are looking for