Dreamweaver MX extracting week number

My form collects a date (which the user picks from a pop-up
calendar). That date is submitted to a field (datBegin) in the
MySQL database. Fine.
In the process of submitting that date, I want a portion of
it (the "week-number" represented by the date that the user
entered) to be submitted to another field (week_nbr) in the same
MySQL database and table.
In other words, the user enters the date once. When he clicks
submit, the date (like 2007-5-17) is placed in the datBegin field,
and the week number (like 20) should be placed in the week_nbr
field.
The formating of the week number is not a problem. It is done
with DATE_FORMAT(datBegin,'%u'). But the submitting of it to the
database is what I am not able to accomplish. The date and the week
number are of course part of the same record (row).
If anyone can help, I'd greatly appreciate it. (I have run
out of things to try!) Most of my attempts have been to create a
value for week_nbr in a hidden field. I have also tried the
DATE_FORMAT in Recordsets. None of this has been succesful in
getting a week_nbr value (based on the just entered datBegin)
stored to the MySQL database.
I use PHP and work with Dreamweaver MX.

Hi David Powers,
Thanks for your input regarding the week number problem.
re.
> The way to do it is to use
DATE_FORMAT(datBegin,'%u') as part of your query. For
example:
SELECT thisCol, thatCol, DATE_FORMAT(datBegin,'%u') as
week_num
FROM mytable
ORDER BY week_num DESC
This is exactly what I have tried over and over again, many
times. This
approach fails when you add the WHERE statement:
WHERE kalendar.week_nbr = servicegrupp.vecka
However, when I hard code the week_nbr into the kalendar
table, then the
WHERE statement works as intended. There is a match, in other
words.
It appears that the reason it does not work unless the
week_nbr is in the
table, is that "week_num" (as you have it) from the query is
not a field but
something else, perhaps a variable. I'm not sure about the
terminology. To
match output from the table with output from an AS statement
in the query
does not work -- at least not in my experience.
I guess the scenario is one of relations. In other words the
"week_nbr"
from the kalendar table relates to the "vecka" in the
servicegrupp table.
When both are present in their respective tables, the match
occurs.
To try to match them at the output stage, using the AS
statement in the
query, does not work. The wrong "week_nbr" is inserted --
always the number
from the top record in the table, it appears.
I know that in the case of relational tables, it is possible
to output the
id from one table to the foreign key in the related table. It
is this
facility I need to find, somehow, even though I am not
dealing with the ids.
These are my reasonings at the moment. But there is probably
a better, more
elegant way to accomplish the needed match.
Thanks again for your willingness to help.
Curt L. Gustafsson
----- Original Message -----
From: [email protected]
To: [email protected]
Sent: Thursday, May 31, 2007 7:31 PM
Subject: Dreamweaver Support subscription update.
Newsgroup User has posted a message entitled Re: Dreamweaver
MX extracting
week number.
Message Posted on: Thursday May 31,2007 10:31:12 AM
curtgus wrote:
> In the process of submitting that date, I want a portion
of it (the
> "week-number" represented by the date that the user
entered) to be
submitted to
> another field (week_nbr) in the same MySQL database and
table.
You don't need to. The information stored in datBegin already
contains
that information, as you point out yourself.
> The formating of the week number is not a problem. It is
done with
> DATE_FORMAT(datBegin,'%u').
You're approaching the problem the wrong way. You presumably
want to
store the week number so that you can search according to
week number or
display results by week number. The way to do it is to use
DATE_FORMAT(datBegin,'%u') as part of your query. For
example:
SELECT thisCol, thatCol, DATE_FORMAT(datBegin,'%u') as
week_num
FROM mytable
ORDER BY week_num DESC
David Powers, Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
You can view the message at
http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?catid=189&threadid=1272474&fo rumid=12.

Similar Messages

  • How to display week number in a report

    Hi,
    I need to show the week number in a report and related sales data for that week. For example, starting from 01-JUL-2009 the week1 should show total of sales from 01-JUL-08-JUL.
    Help please....
    Thanks
    A/A

    If you are trying to extract the week number of the calender year...you can use..
    sql> select to_char(sysdate,'WW') from dual;
    TO
    05and then group the sales figures by week...
    sql> create table t(
      2     target_date date,
      3     sales       number);
    Table created.
    sql> begin
      2     for i in 1..30 loop
      3        insert into t values (sysdate-i,100*i);
      4     end loop;
      5   commit;
      6  end;
      7  /
    PL/SQL procedure successfully completed.
    sql> select week, sum(sales) from (
      2     select sales, to_char(target_date,'WW') week from t)
      3   group by week;
    WE SUM(SALES)
    05       2100
    02      16800
    01       8800
    04       7000
    03      11900However, if your week calculation starts with a particular date like a calender year starting with 01-june-2010, then you would need to calculate the (relative) week number using something like...
      1  select target_date,
      2         trunc(((target_date - to_date('01-june-2010','DD-MON-YYYY'))/7)) week_number
      3*   from t
    sql> /In the above code, 01-june-2010 is the date from which my calender year starts.
    Please note that since this is relative, you might get negative numbers for weeks.

  • Calendar to get week number of current month

    Hi All,
    Description: Currently I am working on an application which require to calculate some data for current month from a database where I have the data of all the previous and current month of that year, I can take week number as criteria.
    Help Required: I can find week of month or year using Calendar methods but how to find the first week on the current month only.
    Lets suppose the current month is April so when I use, int weekofmonth = cal.get(cal.WEEK_OF_MONTH);
    it will return me the number of present week however I want to get what would be the week number at the start of the month (April).
    Hope I am able to describe my query properly.
    Thanks in advance.
    Amit

    / ====================================================
    Method: Get the desired Date format for the date
    Developed By: Sandip Waghole [29-Jan-2010]
    ==================================================== /
    public String getWeekNo(String strDate)
    // input Date Format : M/dd/yyyy
    int weekNo=0,i=0;
    String strWeekNo=null;
    int noOfDaysInTheYear=365;
    int WEEK_STARTS_ON = 1; // Define the day on which week starts Sunday/Monday 1:Sunday 2:Monday
    int firstDayNoInFirstWeekOfPresentYear=0; // Inititalize teh day on which week is starting in present year
    int firstDayOfPresentYear=0; // Inititlize the 1st day of the present year whether Sunday/Monday/.....
    int[] monthDaysArray = {31,28,31,30,31,30,31,31,30,31,30,31}; // Define array of the days as per months
    int todaysDayNoInPresentYear=0;
    int daysLateByFirstWeekStartedAfterYearStarted=0;
    int intTemp=0;
    //strDate="08/24/2000"; // For test purpose
    StringTokenizer strDateTok = new StringTokenizer(strDate, "/ ");
    int month = Integer.parseInt(strDateTok.nextToken());
    int day= Integer.parseInt(strDateTok.nextToken());
    int year = Integer.parseInt(strDateTok.nextToken());
    GregorianCalendar cal = new GregorianCalendar();
    // Check if present year is leap year
    boolean boolIsLeapYear = cal.isLeapYear(year);
    // If it is boolean year then add 1 to total days in the year & add one more day to february
    if(boolIsLeapYear)
    noOfDaysInTheYear=noOfDaysInTheYear+1;
    monthDaysArray[1]=monthDaysArray[1]1;
    // Find the 1st day of this year
    Calendar calObj = new GregorianCalendar(year, Calendar.JANUARY, 1);
    firstDayOfPresentYear = calObj.get(Calendar.DAY_OF_WEEK);
    int intRemoveNoOfDaysFromWeek=0;
    // # Find the day no of prsent day
    for(i=0;i<month;i+) // get no of days till present year
    intTemp = intTemp monthDaysArray;
    todaysDayNoInPresentYear = intTemp - (monthDaysArray[month-1]-day);
    if(firstDayOfPresentYear==6 || firstDayOfPresentYear==7) // If first Day is Friday or Saturday then it is week
    // Identify the the day no on which 1st week of present year is starting
    firstDayNoInFirstWeekOfPresentYear = 7 - firstDayOfPresentYear WEEK_STARTS_ON 1;
    // Find delay in the 1st week start after r=the year start
    daysLateByFirstWeekStartedAfterYearStarted = firstDayNoInFirstWeekOfPresentYear - 1;
    // Now week is starting from Sunday
    weekNo = (Integer)((todaysDayNoInPresentYear-daysLateByFirstWeekStartedAfterYearStarted)/7);
    // Find the day no of today
    intTemp = (todaysDayNoInPresentYear-daysLateByFirstWeekStartedAfterYearStarted) % 7;
    if(intTemp > 0)
    weekNo=weekNo+1;
    else
    weekNo=weekNo;
    else
    // 1st week is starting on 1st Of January
    firstDayNoInFirstWeekOfPresentYear=firstDayOfPresentYear;
    // Remove no. of days from the 1st week as week is starting from odd Sunday/Monday/Tuesday/Wednesday/Thursday
    intRemoveNoOfDaysFromWeek = 7-firstDayOfPresentYear 1; // 1 added as include start day also
    // So one week will be added in no. of weeks
    weekNo = (Integer)((todaysDayNoInPresentYear-intRemoveNoOfDaysFromWeek)/7);
    // Find the day no of today
    intTemp = (todaysDayNoInPresentYear-intRemoveNoOfDaysFromWeek) % 7;
    weekNo = weekNo +1; // As 1st weeks days are reduced from the todays day no in the year
    if(intTemp > 0)
    weekNo=weekNo+1;
    else
    weekNo=weekNo;
    // Remove the no. of days from the week 1
    strWeekNo=Integer.toString(weekNo);
    return strWeekNo;
    // Any issues please mail on [email protected] or [email protected]

  • How to format a date to display the ISO week number in BI Publisher ?

    Hi there,
    I need to format a date to display the ISO week number in BI Publisher.
    I've tried the following <?format-date:NEED_BY_DATE;'WW'?>, but it returns a week number (1-53) where week 1 starts on the first day of the year and continues to the seventh day of the year, which is not what I want.
    I want the ISO week number (1-52 or 1-53), the one implemented by the 'IW' format mask of the Oracle PL/SQL TO_CHAR() function for example.
    I've tried using 'IW' format mask, but it is not recognised by BI Publisher.
    Also, as I'm working on an RTF template, I've tried 'IW' as MS Word date format, but it is not recognised by MS Word :-((
    Any help would be much appreciated,
    Regards - Hugues

    Hi,
    Thank you for the post.
    The thing is I don't have access to the query, unless I modify a standard E-Businees Suite view (one of those used to generate the PO document in Purchasing).
    Regards - Hugues

  • Why is the week number in iCal not ISO8601?

    why is the week number in iCal not ISO8601?

    Error "The serial number is not valid for this product" | Creative Suite

  • How to get week number and day in my result?

    hi experts, i have given the data is ID and DATE(yyyymmdd),i want to get output like ID,DATE,WEEKNO,YEAR,MONTH,DAY. how to get this output.
    thanks & regards
    vijay

    In a routine transformation you can call function
    DATE_GET_WEEK
    to get the week number from the date.
    To determ the others, use the substring
    YEAR = DATE(4)
    MONTH = DATE+4(2)
    DAY = DATE+6(2)

  • Derive week number of that month

    Hi,
    I need to derive week number based on month.
    Ex:
    Sy-datum = 10.10.2010
    Month: 10.2010
    Calweek: 40.2010
    Week no: 2
    Sy-datum = 11.10.2010
    Month: 10.2010
    Calweek: 41.2010
    Week no: 3
    So for everymonth I need to store the week no in the cube
    Ex
    Date--Month--
    calweek............weekno
    10.10.2010.............10.2010.............40.2010...............2
    10.10.2010.............10.2010.............40.2010...............2
    10.10.2010.............10.2010.............40.2010...............2
    11.10.2010.............10.2010.............41.2010...............3
    11.10.2010.............10.2010.............41.2010...............3
    11.10.2010.............10.2010.............41.2010...............3
    So here i need to derive week number for a date in the month
    Can anyone please help what logic to be applied to get the week number?
    Thanks
    Annie
    Edited by: Annie on Oct 14, 2010 7:48 AM

    Hi Annie, I'm not very sure of any function modules, but you may try this logic:
    1. Date Format Stored in SAP: YYYYMMDD.
    2. Use a formula X+6(2) to get the DD part.
    3. Use Conversion Exit  'CONVERSION_EXIT_ALPHA_INPUT'
    4. Logic: [ DATUM's DD ] MOD 7 which gives the week # ordering for the particular month.
    5. Close the START Routine passing the temp value to RESULT.
    DATA:var_dd type sy-datum, var_temp(2) type i.
    var_dd = SOURCE_FIELDS-ZDATE+6(2).
          CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
            EXPORTING
              INPUT  = var_dd
            IMPORTING
              OUTPUT = var_dd.
    if sy-subrc = 0.
    var_temp = var_dd MOD 7.
    end if.
    RESULT = var_temp.
    Pls. review & let me know your comments.
    Thanks.
    Edited by: Arun Bala G on Oct 14, 2010 12:22 PM

  • Query to  get  Week number  Pls help

    I need to get week number of the current year in the format 2008-W47 ( this is for sysdate
    when i try
    select to_CHAR(sysdate,'YYYY'||'-IW')
    FROM DUAL
    i get 2008-47
    but in the format 2008-W47
    Help
    s

    SQL> select to_CHAR(sysdate,'YYYY')||'-W'||to_char(sysdate,'IW') from dual
      2  /
    TO_CHAR(
    2008-W47

  • Best method to determine the week number of a month - SQL Server 2012

    Hi,
    I'm searching the most valid and tested method to determine the week number respect to a month.
    Fe, the 1st January falls in the 1st week of January, the 1st February fall in the 1st week of February, and so on.
    I've found many solutions but I'd like to know possibly the best one.
    Thanks

    Hi Uri,
    SELECT DATEPART(week, '20150104')
         - DATEPART(week, CONVERT(CHAR(6), '20150104', 112)+'01')
         + 1
    returns 2 and not 1. It's a Sunday.
    Waiting to be spoonfed, eh?
    The one-off in my query would be very simple to figure out - I forgot to add the +1. Is too much to expect from you that you could figure it out yourself?
    And likewise, in my post I said that you should use "week" for weeks starting on Sunday, and "iso_week" if your week starts on Monday. Uri neglected to observe this, but you had the information to correct it. If you had been interested
    in doing some work yourself, that is.
    Nevertheless, there is an issue that I overlooked:
    DECLARE @day date = '20160105'
    SELECT datepart(iso_week, @day) -
           datepart(iso_week, convert(char(6), @day, 112) + '01') + 1
    This returns -51. This is because with ISO week numbering, Jan 1st falls into week 53 of the previous year, if it's on a Friday or later. Week 1 is always the week of Jan 4th. When you week this does not happen, as week 1 is always the week with Jan
    1st. (Dec 31st is always in week 53 or 54.)
    To correct for this, we need this query:
    SELECT DATEPART(iso_week, @day) -
           CASE WHEN DATEPART(iso_week, CONVERT(CHAR(6), @day, 112) + '01') < 50
                THEN DATEPART(iso_week, CONVERT(CHAR(6), @day, 112) + '01')
                ELSE 1
           END + 1
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Rollover 18 weeks starting from week number of current month

    Hi,
    I have a requirement as described below.
    Table Name Time:
    Columns: Fiscal Year, Fiscal Month and Fiscal Week
    above table has join with sales table and it contain sales data on week basis. so least granularity of data at week level.
    we have a report with columns fiscal year, actual sales and forcast sales. our requirement is to filter the data with following criteria.
    Current Month Filter
    Jan fiscal week between 1-18 of current year
    Feb fiscal week between 5-23 of current year
    March fiscal week between 9-27 of current year
    November fiscal week between week 44 of current year and week 10 of next year
    December
    so with above requirement we need to filter data with rollover 18 weeks starting from week number of current month
    I tried with timestampadd(sql_tsi_week, interval, week) but it's not working as I expacting. Please provide the code/logic to get it done.
    Appreciate your help.
    Thanks
    Jay.

    Jay wrote:
    I need to get rollover 18 week data at anypoint of time starting with week number of 1st of every month to 18 weeks. read my question again and you will be able to understand.You're kind of missing the point to be honest. It's very hard to answer specific questions without the required information. To answer a question like this we need a minimum of:
    1. Oracle version
    2. Sample data (CREATE TABLE / INSERT statements)
    3. Expected output
    4. Explanation of business rules.
    Alternatively, you can read the link in my original response.
    Please provide the required information and someone can help.

  • Get Week Number of Current Month

    How can I get the week number of the current month (1-5)?
    This is what I have tried and I'm not getting the expected
    results.

    quote:
    Originally posted by:
    DJ5MD
    Does your go 1-5 since it's only 30 days? Is that the
    difference?
    I think he was referring to your comment "How can I get the
    week number of the current month (1-5)?". Some months can have 6
    weeks so you should take that into account.
    Both the function from cflib.org and his code should return 6
    for 2007-09-30.

  • Week Number of the current week...URGENT

    hi gurus,
    I want to calculate the week number of the current week as per Fiscal year.
    What variable or the Customer Exit code needs to be written for it?
    regards

    Hi Venu,
       Use the code below. I assume that the client is US based where the Fiscal Year starts 1st October every year.  Just in case the fiscal year starts in some other month then adjust the code (if SY-DATUM+4(2) >= 10.) below. Hope this helps.
    DATA: PFY(8)   TYPE C.
    DATA: CFY(4)   TYPE C.
    DATA: LFY      TYPE I.
    DATA: FYD      TYPE I.
    DATA: TWD      TYPE I.
    DATA: RES      TYPE I.
    if SY-DATUM+4(2) >= 10.
      concatenate SY-DATUM+0(6)
                  '01'
             into PFY.
    else.
      LFY = SY-DATUM+0(4).
      LFY = LFY - 1.
      CFY = LFY.
      concatenate CFY
                  SY-DATUM+4(2)
                  '01'
             into PFY. 
    endif.
    FYD = P_FY.
    TWD = SY-DATUM.
    RES = ( TWD - FYD ) / 7.
    Write: Res.

  • IPCC 7 Determine the week number of a month

    Hello,
    I am working towards determine the week number of month and make appropriate routing changes only for that specific week. I have tried using the trunc(), getdate() and weekday(). But i fail to get the week number of a month, but I believe I have managed to the week number of a year.
    The example I have considered is: On Tuesday and Thursdays in second week of every month the calls to be routed to a different skillgroup.
    Please let me know if anyone has any suggestion for this.
    Thanks,
    FYI,
    CM 4.1, CRS 3.5, ICM 7.1

    Hi buddy,
    Great stuff!! Your link gave me another hint of the possible solution, I was working on ICM but not sure why i did not consider CRS for this requirement , The CRS has a builtin function, I have used this builtin Methods which provided me what i expected.
    The debug on the script resulted the week of the month for today which is "4".
    Please let me know your view.
    Thanks again!

  • How to get the week number of year from a Date object?

    Hi!
    I would like to know the week number of the year from a specified Date.
    I dont know how to set the first day of week, and set the minimum days of a week.
    I want to use Monday for first day of week, and at least 4 days of month in a week.
    For example if its 1st, January is Friday, then the first week starts on 4th, Monday.
    Anyone can help?

    Sorry. I should think before I move.
         public static int getWeekOfYear(Date date) {
             Calendar calendar = Calendar.getInstance();
             calendar.setTime(date);
             calendar.setFirstDayOfWeek(Calendar.MONDAY);
             calendar.setMinimalDaysInFirstWeek(4);
             return calendar.get(Calendar.WEEK_OF_YEAR);
         }

  • How do I set twice monthly events based on the week number

    Greetings all. I can't seem to navigate this help system, so hopefully I'm not reasking something that's already been asked. But I have a problem with iCal that I just can't figure out of find an answer to. I need to create a twice monthly event, but it's based on the week number, not every two weeks. For example, I need to be able to create an event for the 2nd and 4th Mondays of the month. Is that possible with iCal? Thanks for your help... and not laughing at me
    Steve

    No problem.
    Go to Monday select the day you want. Create new Event. Then select repeat and you will come up with how you want to repeate it. Select Monthly and then do the following:

Maybe you are looking for

  • TS1538 my iphone 4 isn't recognised by windows 7 ultimate pc or itunes. doesn't charge either

    my iphone 4 works fine in all respects except when I connect it to my pc. the pc doesn't recognise it and when connected to the pc it doesn't charge in itunes it doesn't appear as a connected device.

  • RAID Mirror using partitions

    Hi all, I've got 3 Samsung Spinpoint F1 1TB drives in my MacPro. One is dedicated entirely to Time Machine backup. The other two I would like to split into two equal partitions and then setup RAID (mirror) arrays using Disk Utility like this: RAID 1

  • Google chrome virus november 2014

    Google Chrome became infected. I have tried to delete a google chrome "googlechrome.dmg" file from my downloads folder and I can't. Help malware problem ensued.

  • Problems installing Adobe Elements 4.0

    Wow, do I love my Macbook Pro. No waiting to order it. Got it 3 weeks ago at the Apple Store. No noise, no problem installing my old files .etc. However, tonight I tried to install Adobe Elements 4 two times. Both times at the last seconds of install

  • Problem in Check-in of originals through CDESK

    Hi, I am facing problem in checking-in originals through CAD Desktop. Problem statement: Once the DIR's are created for CAD documents in CAD Desktop, On Performing Checkin operation, i am getting following error "An error during Check-in may have cau